Tuesday, December 31, 2013

The Oracle base has been set to Parse failed, error 229

Error:
In line 0 of oraclehomeproperties.xml:
LPX-00229: input source is empty
The Oracle base has been set to Parse failed, error 229

Cause: oraclehomeproperties.xml file got corrupt

Solution:
  1. cd $ORACEL_HOME/inventory/ContentsXML
  2. use ls -ltr to get the following:
    drwx—— 2 oracle oinstall 4096 Dec 29 2010 ConfigXML
    -rw-r—– 1 oracle oinstall 7770 Feb 21 2011 libs.xml
    -rw-r—– 1 oracle oinstall 1978 Feb 21 2011 config.xml
    -rw-r—– 1 oracle oinstall 656001 Feb 21 2011 comps.xml
    -rw-r–r– 1 oracle oinstall 0 May 19 2013 oraclehomeproperties.xml

    Notice that oraclehomeproperties.xml is of size 0 bytes.
  3. To fix the issue either restore oraclehomeproperties.xml from backup or copy it from another ORACLE_HOME of a different database

Friday, December 20, 2013

SQL Server database capacity planning notes

It is best not to rely on auto-growth of the database because it negatively affects the performance and also causes database files to become fragmented because during auto-growth large chunks of disk space are being allocated.

One can set an auto-growth just as a way to prevent any issues but still monitor database growth proactively. Also it is best to set auto-growth percentage to a reasonable number in order to keep the database from using more space than it needs.

The best time to grow a database is during offline maintenance window. Allocate new space to the database files (mdf and ldf), close the dtaabase and defragment the filesystem on which database resides.

Rebuilding indexes also helps to combat fragmentation by deleting an old index and building a fresh one, leaving space for new data.

Tuesday, December 17, 2013

How to grant a user read-only rights to a schema in Oracle 11g

There are two ways to grant a user read-only privileges on a single schema in Oracle:

1) Retrieve all the objects and grant SELECT privileges on each object to the user in question

2) Create a role and to that role grant SELECT privileges on each object in the schema and then grant that role to the user.

Script below can spool all the necessary GRANT statements to a file, given username of the user (or role) to grant priileges to and given the nschema name:
set pages 0;
set linesize 100;
set feedback off; 
set verify off; 

spool C:\Test\GET_ALL_SCHEMA_OBJECTS.sql

SELECT 'GRANT SELECT ON ' || table_name || ' TO &&new_user;' FROM dba_tables WHERE owner=upper('&&schema_name');
 
SELECT 'GRANT SELECT ON ' || view_name || ' TO &&new_user;' FROM dba_views WHERE owner=upper('&&schema_name');
 
set serveroutput off;
spool off;


Wednesday, December 4, 2013

How to retrieve all permissions granted to a particular user

Below is the query that will give you all the permissions granted to a particular user for the current database:
SELECT class_desc [Permission Level], CASE WHEN class = 0 THEN DB_NAME()
         WHEN class = 1 THEN OBJECT_NAME(major_id)
         WHEN class = 3 THEN SCHEMA_NAME(major_id) END [Securable]
  , USER_NAME(grantee_principal_id) [User]
  , permission_name [Permission]
  , state_desc
FROM sys.database_permissions
WHERE USER_NAME(grantee_principal_id)='user1'

Tuesday, December 3, 2013

ORA-00600: internal error code, arguments: [13013], [5001], [121347], [12771893], [1], [12771893], [17]. Non-fatal internal error happenned while SMON was doing logging scn->time mapping.

Error: ORA-00600: internal error code, arguments: [13013], [5001], [121347], [12771893], [1], [12771893], [17], [], [], [], [], []. Non-fatal internal error happenned while SMON was doing logging scn->time mapping.

Details: Error occurred in the alert log

Cause: Occurs when smon_scn_time has been corrupted

Solution:. We have 2 choices here
  1. Restore and recover the system tablespace
  2. or
  3. Recreate smon_scn_time

More on the solution here