問題描述
在 SQL Server 上,sys.objects 表包括Type"和Type_Desc"屬性.例如,對于我的一個數據庫:
SELECT DISTINCT [Type], Type_Desc從系統對象按 [類型] 訂購
返回:
<前>C CHECK_CONSTRAINTD DEFAULT_CONSTRAINTF FOREIGN_KEY_CONSTRAINTFN SQL_SCALAR_FUNCTIONFS CLR_SCALAR_FUNCTIONIT INTERNAL_TABLEP SQL_STORED_PROCEDUREPK PRIMARY_KEY_CONSTRAINT系統表SQ SERVICE_QUEUETR SQL_TRIGGER用戶表昆士蘭大學 UNIQUE_CONSTRAINT視圖不同的 DB 有不同的結果,具體取決于使用的類型.
某處是否有這些類型的完整列表?對 sys.objects 沒有約束指向這些表,并且 sys.types 包含數據類型.我搜索過 SQL BOL 但沒有找到.任何幫助,將不勝感激.
一些數據庫只使用這些類型的一個子集.例如,如果我有一個沒有視圖的數據庫,當我按上述方式查詢 Sys.Objects 時,結果中沒有V"行.我正在尋找 SQL Server 使用的所有可能類型和描述的列表.
BOL 有一個完整的列表,但你不能加入.
AF = 聚合函數 (CLR)C = 檢查約束D = DEFAULT(約束或獨立)F = 外鍵約束FN = SQL 標量函數FS = 匯編 (CLR) 標量函數FT = 匯編 (CLR) 表值函數IF = SQL 內聯表值函數IT = 內表P = SQL 存儲過程PC = 匯編 (CLR) 存儲過程PG = 計劃指南PK = PRIMARY KEY 約束R = 規則(舊式,獨立)RF = 復制過濾程序S = 系統基表SN = 同義詞SQ = 服務隊列TA = 匯編 (CLR) DML 觸發器TF = SQL 表值函數TR = SQL DML 觸發器TT = 表格類型U = 表(用戶定義)UQ = 唯一約束V = 視圖X = 擴展存儲過程
轉到此信息的最佳 SQL Server 源:sys.objects (Transact-SQL) 它沒有提到要加入的任何表.我不能說我曾經注意到任何系統表或視圖都可以連接到代碼表.
我猜您必須創建自己的表或視圖,或者只使用 sys.objects 中的 Type_Desc 屬性.
On SQL Server, the sys.objects table includes "Type" and "Type_Desc" attributes. For example, for one of my DBs:
SELECT DISTINCT [Type], Type_Desc
FROM Sys.Objects
ORDER BY [Type]
Returns:
C CHECK_CONSTRAINT D DEFAULT_CONSTRAINT F FOREIGN_KEY_CONSTRAINT FN SQL_SCALAR_FUNCTION FS CLR_SCALAR_FUNCTION IT INTERNAL_TABLE P SQL_STORED_PROCEDURE PK PRIMARY_KEY_CONSTRAINT S SYSTEM_TABLE SQ SERVICE_QUEUE TR SQL_TRIGGER U USER_TABLE UQ UNIQUE_CONSTRAINT V VIEW
Different DBs have different results, depending on what types are used.
Is there a comprehensive list of these types somewhere? There isn't a constraint on sys.objects that points me to table of these, and sys.types contains data types. I've searched SQL BOL but haven't found it. Any help would be appreciated.
EDIT: Some DBs use only a subset of these types. For example, if I have a database with no views, when I query Sys.Objects as above, there are no "V" rows in the results. I am looking for a list of all possible types and descriptions used by SQL Server.
BOL has a complete list, but you can't join on that.
AF = Aggregate function (CLR)
C = CHECK constraint
D = DEFAULT (constraint or stand-alone)
F = FOREIGN KEY constraint
FN = SQL scalar function
FS = Assembly (CLR) scalar-function
FT = Assembly (CLR) table-valued function
IF = SQL inline table-valued function
IT = Internal table
P = SQL Stored Procedure
PC = Assembly (CLR) stored-procedure
PG = Plan guide
PK = PRIMARY KEY constraint
R = Rule (old-style, stand-alone)
RF = Replication-filter-procedure
S = System base table
SN = Synonym
SQ = Service queue
TA = Assembly (CLR) DML trigger
TF = SQL table-valued-function
TR = SQL DML trigger
TT = Table type
U = Table (user-defined)
UQ = UNIQUE constraint
V = View
X = Extended stored procedure
Going to the best SQL Server source for this info: sys.objects (Transact-SQL) it doesn't mention any table to join to. I can't say that I have ever noticed a codes table to join to for any of the systems tables or views.
I guess you'll have to create your own table or view, or just use the Type_Desc attribute in sys.objects.
這篇關于解釋 SQL Server 中 sys.objects 中的類型代碼的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!