Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet67/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   63   64   65   66   67   68   69   70   ...   443
Bog'liq
BookSQL

Check Constraints

A check constraint allows you to define a predicate that a row must meet to be entered into the table 

or to be modified. For example, the following check constraint ensures that the salary column in the 

Employees table will support only positive values.

ALTER TABLE dbo.Employees 

  ADD CONSTRAINT CHK_Employees_salary 

  CHECK(salary > 0.00);

An attempt to insert or update a row with a nonpositive salary value will be rejected by the RDBMS. 

Note that a check constraint rejects an attempt to insert or update a row when the predicate evalu-

ates to FALSE. The modification will be accepted when the predicate evaluates to either TRUE or 

UNKNOWN. For example, salary –1000 will be rejected, whereas salaries 50000 and NULL will both 

be accepted.

When adding check and foreign key constraints, you can specify an option called WITH NOCHECK 

that tells the RDBMS that you want it to bypass constraint checking for existing data. This is consid-

ered a bad practice because you cannot be sure that your data is consistent. You can also disable or 

enable existing check and foreign key constraints.




Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   63   64   65   66   67   68   69   70   ...   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