Sub Zero Wins

Monday, September 12, 2005

Some useful DBA tables

Examples of using the system tables: user_catalog, all_views, all_catalog, all_tab_comments, all_col_comments, all_objects

To see all of the objects you have created (tables, views, sequences):
SELECT * FROM user_catalog;

To see all the Views owned by the user KCDATA:
SELECT view_name FROM all_views WHERE owner = 'KCDATA';

To see all of the objects owned by KCDATA:
SELECT * FROM all_catalog WHERE owner = 'KCDATA';

To see the SQL statement that defines a view:
SELECT text FROM all_views WHERE view_name = 'RPACCT_VIEW';

To see the comments on a table:
SELECT table_name, comments FROM all_tab_comments WHERE table_name = 'RPACCT_EXTR'

To see the comments on a column in a table or view:
SELECT table_name, column_name, comments FROM all_col_comments WHERE table_name = 'RPACCT_EXTR'

To see the date a table was last updated:
SELECT created, last_ddl_time updated FROM all_objects WHERE object_name = 'RPACCT_EXTR';

To create a View that shows all available column comments:
CREATE VIEW comments AS SELECT owner, table_name, comments FROM all_tab_comments WHERE comments IS NOT NULL

To see what fields are in a table or view:
DESCRIBE kcdata.rpacct_extr

0 Comments:

Post a Comment

<< Home