SQL Server:对象名称的最大字符长度


Answers:



56

是的,它是128,临时表除外,临时表的名称最多只能包含116个字符。这是完美的解释

并且可以使用之前博客文章中包含的以下脚本轻松进行验证:

DECLARE @i NVARCHAR(800)
SELECT @i = REPLICATE('A', 116)
SELECT @i = 'CREATE TABLE #'+@i+'(i int)'
PRINT @i
EXEC(@i)

我认为,“恭维”可能意味着“测试”或“验证”。我对吗?
Stephen G Tuggy

20

您还可以使用此脚本找出更多信息:

EXEC sp_server_info

结果将是这样的:

attribute_id | attribute_name        | attribute_value
-------------|-----------------------|-----------------------------------
           1 | DBMS_NAME             | Microsoft SQL Server
           2 | DBMS_VER              | Microsoft SQL Server 2012 - 11.0.6020.0
          10 | OWNER_TERM            | owner
          11 | TABLE_TERM            | table
          12 | MAX_OWNER_NAME_LENGTH | 128
          13 | TABLE_LENGTH          | 128
          14 | MAX_QUAL_LENGTH       | 128
          15 | COLUMN_LENGTH         | 128
          16 | IDENTIFIER_CASE       | MIXED
                                    
                                    
                                    
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.