为什么在CREATE TABLE语句中需要将括号放在ON [PRIMARY]周围? [英] Why are brackets needed to around ON [PRIMARY] in a CREATE TABLE statement?

查看:284
本文介绍了为什么在CREATE TABLE语句中需要将括号放在ON [PRIMARY]周围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近尝试了一些SQL Share视频中的示例代码,并且是T-SQL的新手,我有一个问题希望我能回答.

这是代码示例:

I recently tried some sample code from a SQL Share video and being new to T-SQL I have a question I hope someone will answer.

Here is the code sample:

create table test.Contact
(
	ContactID int identity not for replication not null,
	Title nvarchar(8) null,
	FirstName nvarchar(50) not null,
	MiddleName nvarchar(50) null,
	LastName nvarchar(50) not null,
	Suffix nvarchar(10) null,
	EmailAddress nvarchar(50) not null,
	Phone nvarchar(25) null,
	AddressLine1 nvarchar(60) not null,
	AddressLine2 nvarchar(60) not null,
	City nvarchar(30) not null,
	StateProvinceID int not null,
	PostalCode nvarchar(15) not null,
	constraint PK_Contact_ContactID 
	primary key clustered (ContactID asc)
	with 
	(
		pad_index = off,
		statistics_norecompute = off,
		ignore_dup_key = off,
		allow_row_locks = off
	)
) on [primary];
go



我的问题是,为什么在语句末尾的"primary"关键字周围需要用括号括起来?

我知道有两种情况需要使用方括号,例如关键字(我认为这可能是原因),但是primary被用作关键字而不是对象名称,因此我在表上空白.

在此先感谢您.



My question is why are the brackets needed around the "primary" keyword at the end of the statement?

I know of a couple case where brackets would be necessary such as keywords (I thought this may be why) but primary is being used as a keyword and not as an object name so I drew a blank.

Thanks in advance.

推荐答案

因为要使其正常工作,这是必需的.这是我所知道的最好的.
Because it''s required to make it work. That''s the best I know to tell you.


因为PRIMARY是关键字,在这种情况下,PRIMARY是文件组的名称.
Because PRIMARY is a keyword and in this case PRIMARY is the name of the filegroup.


这篇关于为什么在CREATE TABLE语句中需要将括号放在ON [PRIMARY]周围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆