April 1, 2013 at 5:36 am
why on primary is used while creating a table is it necessary
ex:
create table temp
(name varchar(50),age smallint,salary int)on primary
April 1, 2013 at 6:17 am
Because that you can have more than one filegroup. And that tells SQL Server to create the object in a certain file group. Yes, it is required. That is, I have always typed it. You can look in the SQL BOL to be sure.
Andrew SQLDBA
April 1, 2013 at 6:19 am
AndrewSQLDBA (4/1/2013)
Because that you can have more than one filegroup. And that tells SQL Server to create the object in a certain file group. Yes, it is required. That is, I have always typed it. You can look in the SQL BOL to be sure.Andrew SQLDBA
technically it's not required as far as the CREATE TABLE command goes, but if you leave it off, it gets created on the PRIMARY file group anyway, because that is the default group.
Lowell
April 1, 2013 at 6:32 am
It's not required. Leave it off and the table or index gets created in the default filegroup. That's Primary by default, but can be changed
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 2, 2013 at 6:01 am
Get into a habit of leaving the "on primary" off all your code. When the code gets released the DBA can decide if it is appropriate where the objects (tables, indexes) are supposed to be by defining which filegroup is the default. In general its the DBA and not the developer who is responsible for the file & object placement on the system and in an agile environment under pressure you try getting 20 developers environments to accept multiple file groups!
To turn the auto scripting of then is SSMS
Menu->Tools -> options-> Sql Server Object Explorer->Scripting
scroll down to "Table and view options" then find "Script File Groups" and set the option to false.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply