Skip to content

Instantly share code, notes, and snippets.

@vagmi
Forked from dlokesh/oracle.md
Created April 9, 2013 04:28
Show Gist options
  • Save vagmi/5342969 to your computer and use it in GitHub Desktop.
Save vagmi/5342969 to your computer and use it in GitHub Desktop.

Oracle sqls

find all constraints of a table

select * from all_constraints where table_name='TABLE_NAME' and owner='OWNER_NAME';

find all primary keys of a table

SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
FROM all_constraints cons, all_cons_columns cols
WHERE cols.table_name = 'TABLE_NAME' and cons.owner= 'OWNER_NAME'
AND cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
ORDER BY cols.table_name, cols.position;

find all table comments

select * from all_tab_comments where owner = 'OWNER_NAME' and table_name ='TABLE_NAME';

find all column comments

select * from all_col_comments where owner = 'OWNER_NAME' and table_name ='TABLE_NAME';

find source of stored proc

select text from all_source where owner='OWNER_NAME' and name='PROC_NAME' order by line;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment