1.CREATE TABLE one(sno int,name varchar(40) CONSTRAINT s1 PRIMARY KEY(sno))
2. CREATE TABLE two(sno int PRIMARY KEY,name varchar(40))
Both gives the same result....... Then what is the difference....
Expand the Object Explorer and Reach the key folder of the Table
For NO 1 the primary key with the name s1 but NO 2 have a key with default name
It did the same thing when you will check with sp_help <table name>
So if you use 2 type it is some what informative to you.
It also very useful when you will try to alter the primary key or constraints
like
ALTER TABLE dbo.one DROP CONSTRAINT s1
You will get confusion when you failed to give the name to the constraints like PRIMARY KEY or FOREIGN KEY.......
2. CREATE TABLE two(sno int PRIMARY KEY,name varchar(40))
Both gives the same result....... Then what is the difference....
Expand the Object Explorer and Reach the key folder of the Table
For NO 1 the primary key with the name s1 but NO 2 have a key with default name
It did the same thing when you will check with sp_help <table name>
So if you use 2 type it is some what informative to you.
It also very useful when you will try to alter the primary key or constraints
like
ALTER TABLE dbo.one DROP CONSTRAINT s1
You will get confusion when you failed to give the name to the constraints like PRIMARY KEY or FOREIGN KEY.......
No comments:
Post a Comment