Oracle DB: Locked objects

Find out which objects are locked using the following query:   select   substr(a.os_user_name,1,15) "OS User",   substr(a.oracle_username,1,8) "DB User",   substr(b.owner,1,8) "Schema",   substr(b.object_name,1,20) "Object Name",   substr(b.object_type,1,10) "Type",   substr(c.segment_name,1,15) "RBS",   substr(d.used_urec,1,12) "# of Records",  …

Continue ReadingOracle DB: Locked objects

Oracle DB: Add/Drop/Rename objects

Some sample commands for Add/Drop/Rename objects:--Dropping the primary key:ALTER TABLE "VAG"."TEST_TABLE" drop primary key;drop index "VAG"."TEST_TABLE_PK";--Adding primary key:CREATE UNIQUE INDEX "VAG"."TEST_TABLE_PK" ON "VAG"."TEST_TABLE" ("TEST_TABLE_ID");ALTER TABLE "VAG"."TEST_TABLE" ADD CONSTRAINT "TEST_TABLE_PK" PRIMARY…

Continue ReadingOracle DB: Add/Drop/Rename objects

Oracle PL/SQL: Autonomous Transaction for logging

Here is an example how to use autonomous_transaction for logging purposes.In case of rollback only the main transaction is affected.declare    l_categories_count      varchar2(100);    process_error            Exception;        procedure log(p_message varchar2) is        …

Continue ReadingOracle PL/SQL: Autonomous Transaction for logging

Oracle DB: Extract DDL without storage specifications

For exporting the DDL of data objects without the storage specifications, this is what we should do:EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);select DBMS_METADATA.GET_DDL('TABLE','PROJECTS') from DUAL;EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'DEFAULT');

Continue ReadingOracle DB: Extract DDL without storage specifications