What's the difference between primary key and unique index? At this point,
they are the same to me, but I could be wrong. Thank you in advance for
your comments.When you create a primary key, sqlserver will implement an unique index on
the column(s).
-oj
http://www.rac4sql.net
"Zeng" <zzy@.nonospam.com> wrote in message
news:%23X%23glov3DHA.3656@.TK2MSFTNGP11.phx.gbl...
quote:
> Hello,
> What's the difference between primary key and unique index? At this
point,
quote:|||Hi,
> they are the same to me, but I could be wrong. Thank you in advance for
> your comments.
>
If you create a primary key, by default it will create clustered index (if
there doesn't exist any) on that column(s) and if you create a unique key
then by default it will create non-clustered index on the column(s).
- Kanth
"Zeng" <zzy@.nonospam.com> wrote in message
news:%23X%23glov3DHA.3656@.TK2MSFTNGP11.phx.gbl...
quote:
> Hello,
> What's the difference between primary key and unique index? At this
point,
quote:|||A primary key a logical concept which is declared for integrity reasons.
> they are the same to me, but I could be wrong. Thank you in advance for
> your comments.
>
Indexes are physical artifacts added mostly for performance reasons. A table
can have only one primary key while a table can have more than one indexes.
Primary key columns must be non-nullable while unique index columns can be
nullable even though only one NULL is allowed (even for unique index on
multiple columns). Primary keys guarantee uniqueness irrespective of any
operations in the table while certain option on unique indexes can ignore
new or updated data that would create a duplicate key in the index. In SQL
Server, a declaration of primary key results in the creation of an index, by
default.
- Anith
( Please reply to newsgroups only )|||1. Primary Key is a field or group of fields within the table that uniquely
identifies thge record.
2. It cannot be repeated in any sybsequent row no matter how many rows are
added.
3 .Groups of primary key = Composite key.
1. SQL Server automatically creates an index for the table's PRIMARY KEY.
2. Totally we can have 250 Indexes. {Includes only 1 Clustered + 249 Non
Clustered}
3. Unique index contains no Duplicate values.
Bhaskaran.B
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:#NdUGex3DHA.2460@.TK2MSFTNGP10.phx.gbl...
quote:
> A primary key a logical concept which is declared for integrity reasons.
> Indexes are physical artifacts added mostly for performance reasons. A
table
quote:
> can have only one primary key while a table can have more than one
indexes.
quote:
> Primary key columns must be non-nullable while unique index columns can be
> nullable even though only one NULL is allowed (even for unique index on
> multiple columns). Primary keys guarantee uniqueness irrespective of any
> operations in the table while certain option on unique indexes can ignore
> new or updated data that would create a duplicate key in the index. In SQL
> Server, a declaration of primary key results in the creation of an index,
by
quote:|||1. Primary Key is a field or group of fields within the table that uniquely
> default.
> --
> - Anith
> ( Please reply to newsgroups only )
>
identifies thge record.
2. It cannot be repeated in any sybsequent row no matter how many rows are
added.
3 .Groups of primary key = Composite key.
1. SQL Server automatically creates an index for the table's PRIMARY KEY.
2. Totally we can have 250 Indexes. {Includes only 1 Clustered + 249 Non
Clustered}
3. Unique index contains no Duplicate values.
Bhaskaran.B
----
"Zeng" <zzy@.nonospam.com> wrote in message
news:#X#glov3DHA.3656@.TK2MSFTNGP11.phx.gbl...
quote:
> Hello,
> What's the difference between primary key and unique index? At this
point,
quote:|||It's all clear to me now. Thank you everybody!
> they are the same to me, but I could be wrong. Thank you in advance for
> your comments.
>
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:%23NdUGex3DHA.2460@.TK2MSFTNGP10.phx.gbl...
quote:
> A primary key a logical concept which is declared for integrity reasons.
> Indexes are physical artifacts added mostly for performance reasons. A
table
quote:
> can have only one primary key while a table can have more than one
indexes.
quote:
> Primary key columns must be non-nullable while unique index columns can be
> nullable even though only one NULL is allowed (even for unique index on
> multiple columns). Primary keys guarantee uniqueness irrespective of any
> operations in the table while certain option on unique indexes can ignore
> new or updated data that would create a duplicate key in the index. In SQL
> Server, a declaration of primary key results in the creation of an index,
by
quote:
> default.
> --
> - Anith
> ( Please reply to newsgroups only )
>
No comments:
Post a Comment