Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

on primary Expand / Collapse
Author
Message
Posted Monday, April 1, 2013 5:36 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 3:08 AM
Points: 68, Visits: 409
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
Post #1437405
Posted Monday, April 1, 2013 6:17 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Tuesday, August 12, 2014 2:35 PM
Points: 975, Visits: 3,350
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
Post #1437413
Posted Monday, April 1, 2013 6:19 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 5:28 AM
Points: 12,910, Visits: 32,013
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1437415
Posted Monday, April 1, 2013 6:32 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 12:33 PM
Points: 42,818, Visits: 35,943
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 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1437420
Posted Tuesday, April 2, 2013 6:01 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 4:19 PM
Points: 51, Visits: 293
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.


Post #1437850
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse