I would like create a table and add to it a Primary Key.
As for my understanding MS SQL add a clustered Index on the Primary Key and will name it with a default name.
I would like to know if is possible create a table and ASSIGN a custom name for the index created by default or how can i change the default name after the table as been created.
Thanks!
Sure - you can define the PRIMARY KEY
constraint in your CREATE TABLE
statement.
This will generate the default PRIMARY KEY
CREATE TABLE dbo.Table
(ID INT IDENTITY PRIMARY KEY,
.......)
but you can totally define the name of the constraint, too:
CREATE TABLE dbo.Table2
(ID INT IDENTITY CONSTRAINT PK_Table2 PRIMARY KEY,
......)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With