1. 程式人生 > 資料庫 >sql server系統表詳細說明

sql server系統表詳細說明

sql server系統表詳細說明

SQL Server 使用者庫中系統表說明

名稱 說明 備註
syscolumns 每個表和檢視中的每列在表中佔一行,儲存過程中的每個引數在表中也佔一行。
syscomments 包含每個檢視、規則、預設值、觸發器、CHECK 約束、DEFAULT 約束和儲存過程的項。text 列包含原始 SQL 定義語句,其最大大小限制為 4 MB。 不應刪除 syscomments 中的項。如果手工刪除或修改 syscomments 中的項,則對應的儲存過程將不能正常工作。若要隱藏或加密儲存過程定義,請使用含有 ENCRYPTION 關鍵字的 Create PROCEDURE。
sysdepends 包含物件(檢視、過程和觸發器)與物件定義中包含的物件(表、檢視和過程)之間的相關性資訊。
sysfilegroups 資料庫中的每個檔案組在表中佔一行。 在該表中至少有一項用於主檔案組。
sysfiles 資料庫中的每個檔案在表中佔一行。 該系統表是虛擬表,不能直接更新或修改。
sysfiles1 資料庫中的每個檔案在表中佔一行。 該系統表是虛擬表,不能直接更新或修改。
sysforeignkeys 包含關於表定義中的 FOREIGN KEY 約束的資訊。
sysfulltextcatalogs 包含關於表定義中的 FOREIGN KEY 約束的資訊。
sysfulltextnotify sysfulltextnotify 檢視未在 SQL Server 2000 中記錄,但仍可查詢它。此檢視在 SQL Server 2005 中已刪除。
sysindexes 資料庫中的每個索引和表在表中各佔一行。
sysindexkeys 資料庫中的每個索引和表在表中各佔一行。
sysmembers 每個資料庫角色成員在表中佔一行。
sysobjects 在資料庫內建立的每個物件(約束、預設值、日誌、規則、儲存過程等)在表中佔一行。 只有在 tempdb 內,每個臨時物件才在該表中佔一行。
syspermissions 包含有關對資料庫內的使用者、組和角色授予和拒絕的許可權的資訊。
sysproperties (sql2005及以上版本使用 sys.extended_properties) 包含表中列的說明描述資訊。
sysprotects 包含有關已由 GRANT 和 DENY 語句應用於安全帳戶的許可權的資訊。
sysreferences 包括 FOREIGN KEY 約束定義到所引用列的對映。
systypes 對於每種系統提供資料型別和使用者定義資料型別,均包含一行資訊。 這些是系統提供的資料型別及其 ID 號。
sysusers 資料庫中每個 Microsoft? Windows 使用者、Windows 組、Microsoft SQL Server? 使用者或 SQL Server 角色在表中佔一行。

1.syscolumns****表

列名 資料型別 描述
name sysname 列名或過程引數的名稱。
id int 該列所屬的表物件 ID,或與該引數關聯的儲存過程 ID。
xtype tinyint systypes 中的物理儲存型別。
typestat tinyint 僅限內部使用。
xusertype smallint 擴充套件的使用者定義資料型別 ID。
length smallint systypes 中的最大物理儲存長度。
xprec tinyint 僅限內部使用。
xscale tinyint 僅限內部使用。
colid smallint 列或引數 ID。
xoffset smallint 僅限內部使用。
bitpos tinyint 僅限內部使用。
reserved tinyint 僅限內部使用。
colstat smallint 僅限內部使用。
cdefault int 該列的預設值 ID。
domain int 該列的規則或 CHECK 約束 ID。
number smallint 過程分組時(0 表示非過程項)的子過程號。
colorder smallint 僅限內部使用。
autoval varbinary(255) 僅限內部使用。
offset smallint 該列所在行的偏移量;如果為負,表示可變長度行。
status tinyint 用於描述列或引數屬性的點陣圖: 0x08 = 列允許空值。 0x10 = 當新增 varchar 或 varbinary 列時,ANSI 填充生效。保留 varchar 列的尾隨空格,保留 varbinary 列的尾隨零。 0x40 = 引數為 OUTPUT 引數。 0x80 = 列為標識列。
type tinyint systypes 中的物理儲存型別。
usertype smallint systypes 中的使用者定義資料型別 ID。
printfmt varchar(255) 僅限內部使用。
prec smallint 該列的精度級別。
scale int 該列的小數位數。
iscomputed int 表示是否已計算該列的標誌: 0 = 未計算。 1 = 已計算。
isoutparam int 表示該過程引數是否是輸出引數: 1 = 真。 0 = 假。
isnullable int 表示該列是否允許空值: 1 = 真。 0 = 假。

2.syscomments****表

列名 資料型別 描述
id int 該文字適用的物件 ID。
number smallint 如果進行分組,則為過程分組內的號碼。0 表示不是過程的項。
colid smallint 超過 4,000 個字元的物件定義的行序列號。
status smallint 僅限內部使用。
ctext varbinary(8000) SQL 定義語句的實際文字。
texttype smallint 0 = 使用者提供的註釋。 1 = 系統提供的註釋。 4 = 加密的註釋。
language smallint 僅限內部使用。
encrypted bit 表示過程是否已加密。 0 = 未加密。 1 = 已加密。
compressed bit 表示過程是否已壓縮。 0 = 未壓縮。 1 = 已壓縮。
text nvarchar(4000) SQL 定義語句的實際文字。

3.sysdepends****表

列名 資料型別 描述
id int 物件 ID。
depid int 相關物件 ID。
number smallint 過程號。
depnumber smallint 相關過程號。
status smallint 內部狀態資訊。
depdbid smallint 保留。
depsiteid smallint 保留。
selall bit 如果物件用在 Select * 語句中,則開啟。
resultobj bit 如果正在更新物件,則開啟。
readobj bit 如果正在讀取物件,則開啟。

4.sysfilegroups****表

列名 資料型別 描述
groupid smallint 每個資料庫的唯一組標識號。
allocpolicy smallint 保留。
status int 0x8 = READ ONLY 0x10 = DEFAULT
groupname sysname 檔案組的名稱。

5.sysfiles****表

列名 資料型別 描述
fileid smallint 每個資料庫的唯一檔案標識號。
groupid smallint 檔案組標識號。
size int 檔案大小(以 8 KB 頁為單位)。
maxsize int 最大檔案大小(以 8 KB 頁為單位)。0 值表示不增長,–1 值表示檔案應一直增長到磁碟已滿。
growth int 資料庫的增長大小。0 值表示不增長。根據狀態的值,可以是頁數或檔案大小的百分比。如果 status 包含 0x100000,則 growth 是檔案大小的百分比;否則,它是頁數。
status int growth 值(以兆位元組 (MB) 或千位元組 (KB) 為單位)的狀態位。 0x1 = 預設裝置。 0x2 = 磁碟檔案。 0x40 = 日誌裝置。 0x80 = 自上次備份後已寫入檔案。 0x4000 = 由 Create DATABASE 語句隱性建立的裝置。 0x8000 = 在資料庫建立過程中建立的裝置。 0x100000 = 按百分比而不是按頁數增長。
perf int 保留。
name nchar(128) 檔案的邏輯名稱。
filename nchar(260) 物理裝置的名稱,包括檔案的完整路徑。

6.sysfiles1****表

列名 資料型別 描述
status int growth 值(以兆位元組 (MB) 或千位元組 (KB) 為單位)的狀態位。 0x1 = 預設裝置。 0x2 = 磁碟檔案。 0x40 = 日誌裝置。 0x80 = 自上次備份後已寫入檔案。 0x4000 = 由 Create DATABASE 語句隱性建立的裝置。 0x8000 = 在資料庫建立過程中建立的裝置。 0x100000 = 按百分比而不是按頁數增長。
fileid smallint 每個資料庫的唯一檔案標識號。
name nchar(128) 檔案的邏輯名稱。
filename nchar(260) 物理裝置的名稱,包括檔案的完整路徑。

7.sysforeignkeys****表

列名 資料型別 描述
constid int FOREIGN KEY 約束的 ID。
fkeyid int 具有 FOREIGN KEY 約束的表物件 ID。
rkeyid int 在 FOREIGN KEY 約束中引用的表物件 ID。
fkey smallint 正在引用的列 ID。
rkey smallint 已引用的列 ID。
keyno smallint 該列在引用列列表中的位置。

8.sysfulltextcatalogs****表

列名 資料型別 描述
ftcatid smallint 全文目錄的識別符號。
name sysname 使用者提供的全文目錄名。
status smallint 保留;僅限內部使用。
path nvarchar(260) 使用者提供的根路徑。NULL 值表示使用者未提供路徑,因而使用了預設(安裝)路徑。

9.sysindexes****表

列名 資料型別 描述
id int 表 ID(如果 indid = 0 或 255)。否則為索引所屬表的 ID。
status int 內部系統狀態資訊。
first binary(6) 指向第一頁或根頁的指標。
indid smallint 索引 ID: 1 = 聚集索引 >1 = 非聚集 255 = 具有 text 或 image 資料的表條目
root binary(6) 如果 indid >= 1 和 < 255,root 是指向根頁的指標。如果 indid = 0 或 indid = 255,root 是指向最後一頁的指標。
minlen smallint 最小行大小。
keycnt smallint 鍵的數目。
groupid smallint 在其上建立物件的檔案組 ID。
dpages int 如果 indid = 0 或 indid = 1,dpages 是已用資料頁的計數。如果 indid = 255,其設定為 0。否則是已用索引頁的計數。
reserved int 如果 indid = 0 或 indid = 1,reserved 是分配給所有索引和表資料的頁計數。如果 indid = 255,reserved 是分配給 text 或 image 資料的頁計數。否則是分配給索引的頁計數。
used int 如果 indid = 0 或 indid = 1,used 是用於所有索引和表資料的總頁數。如果 indid = 255,used 是用於 text 或 image 資料的頁計數。否則是用於索引的頁計數。
rowcnt bigint 基於 indid = 0 和 indid = 1 的資料級行計數。如果 indid = 255,rowcnt 設定為 0。
rowmodctr int 對自上次更新表的統計後插入、刪除或更新行的總數進行計數。
xmaxlen smallint 最大行大小。
maxirow smallint 最大非葉索引行大小。
OrigFillFactor tinyint 建立索引時使用的起始填充因子值。不保留該值;然而,如果需要重新建立索引但記不住當初使用的填充因子,則該值可能很有幫助。
reserved1 tinyint 保留。
reserved2 int 保留。
FirstIAM binary(6) 保留。
impid smallint 保留。索引實現標誌。
lockflags smallint 用於約束經過考慮的索引鎖粒度。例如,對於本質上是隻讀的查詢表,可以將其設定為僅進行表級鎖定以使鎖定成本減到最小。
pgmodctr int 保留。
keys varbinary(816) 組成索引鍵的列 ID 列表。
name sysname 表名(如果 indid = 0 或 255)。否則為索引的名稱。
statblob image 統計 BLOB。
maxlen int 保留。
rows int 基於 indid = 0 和 indid = 1的資料級行數,該值對於 indid >1 重複。如果 indid = 255,rows 設定為 0。提供該列是為了向後相容。

10.sysindexkeys****表

列名 資料型別 描述
id int 表 ID。
indid smallint 索引 ID。
colid smallint 列 ID。
keyno smallint 該列在索引中的位置。

11.sysmembers****表

列名 資料型別 描述
memberuid smallint 角色成員的使用者 ID。
groupuid smallint 角色的使用者 ID。

12.sysobjects****表

列名 資料型別 描述
name sysname 物件名。
Id int 物件標識號。
xtype char(2) 物件型別。可以是下列物件型別中的一種: C = CHECK 約束 D = 預設值或 DEFAULT 約束 F = FOREIGN KEY 約束 L = 日誌 FN = 標量函式 IF = 內嵌表函式 P = 儲存過程 PK = PRIMARY KEY 約束(型別是 K) RF = 複製篩選儲存過程 S = 系統表 TF = 表函式 TR = 觸發器 U = 使用者表 UQ = UNIQUE 約束(型別是 K) V = 檢視 X = 擴充套件儲存過程
uid smallint 所有者物件的使用者 ID。
info smallint 保留。僅限內部使用。
status int 保留。僅限內部使用。
base_schema_ver int 保留。僅限內部使用。
replinfo int 保留。供複製使用。
parent_obj int 父物件的物件標識號(例如,對於觸發器或約束,該標識號為表 ID)。
crdate datetime 物件的建立日期。
ftcatid smallint 為全文索引註冊的所有使用者表的全文目錄識別符號,對於沒有註冊的所有使用者表則為 0。
schema_ver int 版本號,該版本號在每次表的架構更改時都增加。
stats_schema_ver int 保留。僅限內部使用。
type char(2) 物件型別。可以是下列值之一: C = CHECK 約束 D = 預設值或 DEFAULT 約束 F = FOREIGN KEY 約束 FN = 標量函式 IF = 內嵌表函式 K = PRIMARY KEY 或 UNIQUE 約束 L = 日誌 P = 儲存過程 R = 規則 RF = 複製篩選儲存過程 S = 系統表 TF = 表函式 TR = 觸發器 U = 使用者表 V = 檢視 X = 擴充套件儲存過程
userstat smallint 保留。
sysstat smallint 內部狀態資訊。
indexdel smallint 保留。
refdate datetime 留作以後使用。
version int 留作以後使用。
deltrig int 保留。
instrig int 保留。
updtrig int 保留。
seltrig int 保留。
category int 用於釋出、約束和標識。
cache smallint 保留。

13.syspermissions****表

列名 資料型別 描述
id int 物件許可權的物件 ID;0 表示語句許可權。
grantee smallint 受許可權影響的使用者、組或角色的 ID。
grantor smallint 被授予或廢除許可權的使用者、組或角色的 ID。
actadd smallint 僅限內部使用。
actmod smallint 僅限內部使用。
seladd varbinary(4000) 僅限內部使用。
selmod varbinary(4000) 僅限內部使用。
updadd varbinary(4000) 僅限內部使用。
updmod varbinary(4000) 僅限內部使用。
refadd varbinary(4000) 僅限內部使用。
refmod varbinary(4000) 僅限內部使用。

14.sysproperties****表

列名 資料型別 描述
id int 該列所屬的表物件 ID,或與該引數關聯的儲存過程 ID。
colid smallint 列或引數 ID。
type tinyint 暫缺。
name sysname 暫缺。
value sql_variant 說明描述資訊。

15.sysprotects****表

列名 資料型別 描述
id int 將這些許可權應用於的物件 ID。
uid smallint 將這些許可權應用於的使用者或組的 ID。
action tinyint 可以有下列許可權之一: 26 = REFERENCES 178 = Create FUNCTION 193 = Select 195 = Insert 196 = Delete 197 = Update 198 = Create TABLE 203 = Create DATABASE 207 = Create VIEW 222 = Create PROCEDURE 224 = EXECUTE 228 = BACKUP DATABASE 233 = Create DEFAULT 235 = BACKUP LOG 236 = Create RULE
protecttype tinyint 可以有下列值: 204 = GRANT_W_GRANT 205 = GRANT 206 = REVOKE
columns varbinary(4000) 將這些 Select 或 Update 許可權應用於的列的點陣圖。位 0 表示所有的列,位 1 表示許可權應用於該列,NULL 表示沒有資訊。
grantor smallint 發出 GRANT 或 REVOKE 許可權的使用者的使用者 ID。

16.sysreferences****表

列名 資料型別 描述
constid int FOREIGN KEY 約束的 ID。
fkeyid int 引用表的 ID。
rkeyid int 被引用表的 ID。
rkeyindid smallint 涵蓋被引用鍵列的被引用表上唯一索引的索引 ID。
keycnt smallint 鍵中的列數。
forkeys varbinary(32) 僅限內部使用。
refkeys varbinary(32) 僅限內部使用。
fkeydbid smallint 保留。
rkeydbid smallint 保留。
fkey1 smallint 引用列的列 ID。
fkey2 smallint 引用列的列 ID。
fkey3 smallint 引用列的列 ID。
fkey4 smallint 引用列的列 ID。
fkey5 smallint 引用列的列 ID。
fkey6 smallint 引用列的列 ID。
fkey7 smallint 引用列的列 ID。
fkey8 smallint 引用列的列 ID。
fkey9 smallint 引用列的列 ID。
fkey10 smallint 引用列的列 ID。
fkey11 smallint 引用列的列 ID。
fkey12 smallint 引用列的列 ID。
fkey13 smallint 引用列的列 ID。
fkey14 smallint 引用列的列 ID。
fkey15 smallint 引用列的列 ID。
fkey16 smallint 引用列的列 ID。
rkey1 smallint 引用列的列 ID。
rkey2 smallint 引用列的列 ID。
rkey3 smallint 引用列的列 ID。
rkey4 smallint 引用列的列 ID。
rkey5 smallint 引用列的列 ID。
rkey6 smallint 引用列的列 ID。
rkey7 smallint 引用列的列 ID。
rkey8 smallint 引用列的列 ID。
rkey9 smallint 引用列的列 ID。
rkey10 smallint 引用列的列 ID。
rkey11 smallint 引用列的列 ID。
rkey12 smallint 引用列的列 ID。
rkey13 smallint 引用列的列 ID。
rkey14 smallint 引用列的列 ID。
rkey15 smallint 引用列的列 ID。
rkey16 smallint 引用列的列 ID。

17.systypes****表

列名 資料型別 描述
name sysname 資料型別名稱。
xtype tinyint 物理儲存型別。
status tinyint 僅限內部使用。
xusertype smallint 擴充套件使用者型別。
length smallint 資料型別的物理長度。
xprec tinyint 伺服器所使用的內部精度。不能在查詢中使用。
xscale tinyint 伺服器所使用的內部小數位數。不能在查詢中使用。
tdefault int 對此資料型別進行完整性檢查的儲存過程的 ID。
domain int 對此資料型別進行完整性檢查的儲存過程的 ID。
uid smallint 資料型別建立者的使用者 ID。
reserved smallint 僅限內部使用。
usertype smallint 使用者型別 ID。
variable bit 可變長度資料型別為 1;否則為 0。
allownulls bit 指出此資料型別的預設為空性。如果 Create 或 Alter TABLE 指定了為空性,那麼該值將替代此資料型別的預設為空性。
type tinyint 物理儲存資料型別。
printfmt varchar(255) 保留。
prec smallint 此資料型別的精度級別。
scale tinyint 此資料型別的小數位數(根據精度)。

18.sysusers****表

列名 資料型別 描述
uid smallint 使用者 ID,在此資料庫中是唯一的。1 是資料庫所有者。
status smallint 僅限內部使用。
name sysname 使用者名稱或組名,在此資料庫中是唯一的。
sid varbinary(85) 此條目的安全性識別符號。
roles varbinary(2048) 僅限內部使用。
createdate datetime 帳戶的新增日期。
updatedate datetime 帳戶的上次修改日期。
altuid smallint 僅限內部使用。
password varbinary(256) 僅限內部使用。
gid smallint 此使用者所屬的組 ID。如果 uid = gid,那麼此條目就定義一個組。
environ varchar(255) 保留。
hasdbaccess int 如果該帳戶有資料庫訪問許可權,則為 1。
islogin int 如果該帳戶是有登入帳戶的 Windows 組、Windows 使用者或 SQL Server 使用者,則為 1。
isntname int 如果該帳戶是 Windows 組或 Windows 使用者,則為 1。
isntgroup int 如果該帳戶是 Windows 組,則為 1。
isntuser int 如果該帳戶是 Windows 使用者,則為 1。
issqluser int 如果該帳戶是 SQL Server 使用者,則為 1。
isaliased int 如果該帳戶以另一個使用者為別名,則為 1。
issqlrole int 如果該帳戶是 SQL Server 角色,則為 1。
isapprole int 如果該帳戶是應用程式角色,則為 1。