gpt4 book ai didi

sql - 函数 OBJECT_ID 的第二个参数

转载 作者:行者123 更新时间:2023-12-04 14:41:46 26 4
gpt4 key购买 nike

我在 Itzik Ben-Gan 的《TSQL Fundamentals》一书中遇到了以下代码。

我了解函数 OBJECT_ID 用于检查特定对象是否存在。但是我对它的第二个参数 N'U' 有点困惑。

我查了一下 MSDN documentation它说第二个参数代表对象类型,但我仍然不明白 N'U' 代表什么。

有人可以向我解释一下它实际上代表什么吗?

IF OBJECT_ID(N'dbo.Employees', N'U') IS NOT NULL
BEGIN
IF OBJECTPROPERTY(OBJECT_ID(N'dbo.Employees', N'U'), N'TableTemporalType') = 2
ALTER TABLE dbo.Employees SET(SYSTEM_VERSIONING = OFF);

最佳答案

如果您点击链接到 types: sys.objects 的页面中的链接

U = Table (user-defined)

**Complete list (as of 2017-01-16)**

Object type:

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
SO = Sequence object

Applies to: SQL Server 2012 through SQL Server 2016.

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

Applies to: SQL Server 2016 through SQL Server 2016, Azure SQL
Database, Azure SQL Data Warehouse, Parallel Data Warehouse.

ET = External Table

关于sql - 函数 OBJECT_ID 的第二个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41669333/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com