介紹一下sql server數據庫中的系統表sysobjects。在每個(gè)數據庫中都存在此表。
sysobjects存放著(zhù)數據庫中的所有對象,如表,列,索引等等。
字段xtype代表對象類(lèi)型,u代表用戶(hù)表,p代表存儲過(guò)程,tr代表觸發(fā)器。
name字段表示對象名稱(chēng)。
以用友數據庫為例
use ufdata_888_2004
查詢(xún)數據庫ufdata_888_2004的用戶(hù)表
select * from sysobjects
where xtype = 'u' and name like 'fa_%'
order by name
查詢(xún)數據庫ufdata_888_2004的存儲過(guò)程
select * from sysobjects
where xtype = 'p' and name like 'fa_%'
order by name
查詢(xún)數據庫ufdata_888_2004的觸發(fā)器
select * from sysobjects
where xtype = 'tr' and name like 'sa_%'
order by name
介紹一下sql server數據庫中的系統表:Syscolumns,在每個(gè)數據庫中都存在此表。
name:名稱(chēng)
id:該列所屬的表對象 ID,或與該參數關(guān)聯(lián)的存儲過(guò)程 ID
select * from Syscolumns
syscolumns和sysobjects連用:
select col.name,obj.name
from syscolumns col join sysobjects obj on col.id = obj.id
where obj.xtype = 'u' and obj.name like 'sa_%'
order by col.name
表syscolumns和systypes連用
select sysobjects.name,systypes.name from syscolumns inner join systypes on syscolumns.type = systypes.type
inner join sysobjects on syscolumns.id = sysobjects.id
where systypes.name = 'datetime' and sysobjects.xtype = 'u' and sysobjects.name like 'sa%'
作者:tshfang
來(lái)源: 泥胚文章寫(xiě)作
http://www.nipei.com 原文地址:
http://www.nipei.com/article/2181