dm的数据库对象---数据库对象查询与管理(2)---约束与索引
程序员文章站
2022-06-02 22:08:54
...
小编上次给大家布置了功课,问大家外键的查询
不知道的小伙伴看我前面的文章:
https://blog.csdn.net/qq_37004878/article/details/109803969
《dm的数据库对象—数据库对象查询与管理(1)—表结构》
小编最近啊,被研发的需求烦的头发都掉了不少,天天泡在《DM7系统管理员手册》的附录中还是有不少成果的,找到了自己想要的系统视图信息。
下面,就让小编将结果给大家展示下:
查询索引
select d.TABLE_OWNER,
c.NAME as table_name,
d.COLUMN_NAME,
b.NAME as index_name,
a.xtype
from sysindexes a,
sysobjects b,
sysobjects c,
all_ind_columns d
where a.ID = b.ID
and b.TYPE$ = 'TABOBJ'
and b.SUBTYPE$ = 'INDEX'
and b.PID = c.ID
and b.NAME = d.INDEX_NAME
and FLAG != 1 and a.XTYPE = 0
and d.TABLE_OWNER not in ('SYS','CTISYS')
and a.ISUNIQUE = 'N'
and b.SCHID not in
(SELECT ID FROM sysobjects
WHERE NAME = 'SYS'
and Name = 'CTISYS')
order by 1,2
查询唯一键:
select d.OWNER as SCH_NAME,
c.NAME as table_name,
d.COLUMN_NAME,
b.NAME as con_name,
a.*
from
syscons a,
sysobjects b,
sysobjects c ,
all_cons_columns d
where a.ID = b.ID
and b.TYPE$ = 'TABOBJ'
and b.SUBTYPE$ = 'CONS'
and b.PID = c.ID
and a.TYPE$ = 'U'
and b.name = d.CONSTRAINT_name
and b.SCHID not in (SELECT ID FROM sysobjects WHERE NAME = 'SYS' )
order by 1,2,4
哈哈哈哈,小编又要向大家布置功课了。不知道查询dm实例下所有唯一索引信息该怎么取呢?千万要注意创建主键和唯一键自带的唯一索引哦~~