Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet64/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   60   61   62   63   64   65   66   67   ...   443
Bog'liq
BookSQL

primary Key Constraints

A primary key constraint enforces uniqueness of rows and also disallows NULL marks in the constraint 

attributes. Each unique set of values in the constraint attributes can appear only once in the table—in 

other words, only in one row. An attempt to define a primary key constraint on a column that allows 



NULL marks will be rejected by the RDBMS. Each table can have only one primary key.

Here’s an example of defining a primary key constraint on the empid attribute in the Employees 

table that you created earlier.

ALTER TABLE dbo.Employees 

  ADD CONSTRAINT PK_Employees 

  PRIMARY KEY(empid);

With this primary key in place, you can be assured that all empid values will be unique and known. 

An attempt to insert or update a row such that the constraint would be violated will be rejected by 

the RDBMS and result in an error.

To enforce the uniqueness of the logical primary key constraint, SQL Server will create a unique in-

dex behind the scenes. A unique index is a physical mechanism used by SQL Server to enforce unique-

ness. Indexes (not necessarily unique ones) are also used to speed up queries by avoiding unnecessary 

full table scans (similar to indexes in books).


Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   60   61   62   63   64   65   66   67   ...   443




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish