Tuesday, May 10, 2011

Oracle – Important Queries

– List of tables in DB
SELECT * FROM TABS
SELECT * FROM USER_TABLES
SELECT * FROM user_all_tables;
SELECT * FROM USER_objects where object_type = ‘TABLE’;
SELECT * FROM ALL_ALL_TABLES;
SELECT * FROM DBA_TABLES; — Need Privileges to run this
SELECT * FROM DICT;
SELECT * FROM DICTIONARY;
– List of table spaces
SELECT * FROM USER_TABLESPACES
– List of previlages on tabel
SELECT * FROM TABLE_PRIVILEGES;
SELECT * FROM table_privilege_map;
– List of constraints
SELECT * FROM user_constraints;
– Get Primary key
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.constraint_type = ‘P’
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
ORDER BY cols.table_name, cols.position;
– Get Schema names
SELECT * FROM ALL_USERS
– Get segment assigned
– All table columns
SELECT * FROM ALL_TAB_COLS

No comments:

Post a Comment