ORACLE查询数据库的表和列以及主键等约束信息

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Melody_Susan/article/details/87874074

根据oracle数据库中的对象名称查询对象信息可以使用 dba_objects 

DBA_OBJECTS describes all objects in the database. Its columns are the same as those in "ALL_OBJECTS".

如:

select * from dba_objects where object_name ='T_TEST_LINK'

根据视图名称查询视图信息可以使用 dba_views

DBA_VIEWS describes all views in the database. Its columns are the same as those in ALL_VIEWS.

select * from dba_views where view_name = 'V_TEST_NOTICE'

根据表名查询列信息可以使用 dba_tab_columns,或者 ALL_TAB_COLUMNS 或者 USER_TAB_COLUMNS

ALL_TAB_COLUMNS describes the columns of the tables, views, and clusters accessible to the current user. To gather statistics for this view, use the ANALYZESQL statement or the DBMS_STATS package.

DBA_TAB_COLUMNS describes the columns of all tables, views, and clusters in the database.

USER_TAB_COLUMNS describes the columns of the tables, views, and clusters owned by the current user. This view does not display the OWNER column.

select * from dba_tab_columns where table_name ='T_TEST_LINK'

根据表名查询索引信息 可以使用 dba_indexes

DBA_INDEXES describes all indexes in the database. To gather statistics for this view, use the SQL ANALYZE statement. This view supports parallel partitioned index scans. Its columns are the same as those in "ALL_INDEXES".

select * from dba_indexes where table_name ='T_TEST_LINK'

根据表名查询主键索引信息 可以使用 dba_constraints

DBA_CONSTRAINTS describes all constraint definitions on all tables in the database. Its columns are the same as those in "ALL_CONSTRAINTS".

select * from dba_constraints where table_name ='TEST_PERSON' and constraint_type ='P'

猜你喜欢

转载自blog.csdn.net/Melody_Susan/article/details/87874074