oracle查看索引及约束,表名

查看索引

SELECT
T.*,
I.INDEX_TYPE
FROM
USER_IND_COLUMNS T,
USER_INDEXES I
WHERE
T.INDEX_NAME = I.INDEX_NAME
AND T.TABLE_NAME = I.TABLE_NAME
----指定表
AND T.TABLE_NAME = '表名'

查找表的外键

SELECT 
c.OWNER AS "数据库",
c.CONSTRAINT_NAME AS "约束名称",
c.CONSTRAINT_TYPE AS "约束类型",
c.TABLE_NAME AS "表名",
cl.COLUMN_NAME AS "字段名"
FROM 
user_constraints c,
user_cons_columns cl
WHERE  
c.CONSTRAINT_NAME = cl.CONSTRAINT_NAME 
AND c.constraint_type = 'R' 
AND c.table_name='表名'

根据外键找约束表和列

select * from user_cons_columns cl where cl.constraint_name = 'PK_GL_VOUCHERASSTR'

查询包所有列及其属性

select t.*,c.COMMENTS from user_tab_columns t,user_col_comments c where t.table_name='TEST_TABLE'

 

posted @ 2023-03-03 16:33  凉了记忆  阅读(264)  评论(0编辑  收藏  举报