Professional Documents
Culture Documents
From:
Sent:
To:
Subject:
Subhakanta Das
Thursday, April 9, 2015 4:30 PM
Domnic DeSouza; Ruchi Shikhar; Dipti Prasad
Oracle Queries That might be useful.
Oracle Queries:
a. Get DDL for a table/index/any database object. (To be executed in script mode).
set heading off;
set echo off;
Set pages 999;
set long 90000;
spool ddl_list.sql
select dbms_metadata.get_ddl('TABLE','DEPT','SCOTT') from dual;
select dbms_metadata.get_ddl('INDEX','DEPT_IDX','SCOTT') from dual;
spool off;
b. Update one table using data from another table.
UPDATE TABLE1 a
SET (COL1,COL2) = (
SELECT COL1,COL2
FROM TABLE2 b
WHERE a.COL3 = b.COL3);
MERGE INTO PRODUCTION a
USING ( select id, name, count
from STAGING ) b
ON ( a.id = b.id )
WHEN MATCHED THEN
UPDATE SET a.name = b.name,
a.count = b.count
c. Reset a Database Sequence:
create or replace
procedure reset_sequence(p_seq in varchar2)
is
l_value number;
begin
1
Here as you can see: the table w_customer_loc_d is referenced in the stored procedure
CW_FIX_CUSTOMER_LOCATIONS.
select
index_name,index_type,table_name,uniqueness,compression,distinct_keys,num_rows,last_analyzed,user_stats,visibility
,partitioned from ALL_INDEXES where table_owner='OBAW';
f.