首页 新闻 会员 周边

园子里的老哥们,帮帮看看有关SQL的问题

0
[已解决问题] 解决于 2016-07-14 11:22

CREATE TABLE [dbo].[tStudent]
(
[cID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_tStudent_cID] DEFAULT (newid()),
[cCreateTime] [datetime] NOT NULL CONSTRAINT [DF_tStudent_cCreateTime] DEFAULT (getdate()),
[cUpdateTime] [datetime] NOT NULL CONSTRAINT [DF_tStudent_cUpdateTime] DEFAULT (getdate()),
......
) ON [PRIMARY] ====》 这里的ON [PRIMARY]是什么意思? 怎么理解?

奇妙能力的主页 奇妙能力 | 菜鸟二级 | 园豆:253
提问于:2016-07-14 09:25
< >
分享
最佳答案
0

ON [PRIMARY] specifies which filegroup the table and the index for the primary key is placed on. PRIMARY is the default filegroup for a database. And for many databases the only filegroups.

For a large database, with dseveral hundreds GB or even more in size, you may want to define multiple filegroups to spread the load over different disks and controllers. In a simple development environment, there is no need for more than a single data file and a single filegroup. (Unless you work with FILESTREAM.)

You can consider ON [PRIMARY] to be white noise. And if you compose your scripts manually, you don't need to include it. SSMS generates this code, since it generates a script with settings and attributes for a table or an index, no matter it's the default or not.

奖励园豆:5
爱编程的大叔 | 高人七级 |园豆:30839 | 2016-07-14 09:32

。。。。好吧,我着实看不懂

奇妙能力 | 园豆:253 (菜鸟二级) | 2016-07-14 09:33

看来翻译,是不是这个ON [PRIMARY]在通常情况下是ssms默认的?

奇妙能力 | 园豆:253 (菜鸟二级) | 2016-07-14 09:37

@奇妙能力:

两个意见:

1、这个目前对你没用。

2、多看书。《SQL Server 从入门到精通》买一本是必须的。

爱编程的大叔 | 园豆:30839 (高人七级) | 2016-07-14 09:40

@爱编程的大叔: 恩,大叔教育的是。

奇妙能力 | 园豆:253 (菜鸟二级) | 2016-07-14 09:41

@奇妙能力: 趁年轻,学英语,不要等十年后后悔。

爱编程的大叔 | 园豆:30839 (高人七级) | 2016-07-14 09:45
其他回答(1)
0

菜鸟,数据库可以有多个文件组,每个文件组里面又可以有多个文件,比如ON [PRIMARY] 里面 PRIMARY就是一个默认的文件组,

你不修改的情况下,它默认有2个文件,一个mdf,一个ldf文件;(不同的文件组物理位置可以不同,可以放在不同的磁盘里面,提高IO速度)

你提问中那句的意思就是在文件组PRIMARY 上面建立一个表;

maanshancss | 园豆:303 (菜鸟二级) | 2016-07-14 11:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册