Sql server® 2012 t-sql fundamentals



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

default Constraints

A default constraint is associated with a particular attribute. It is an expression that is used as the de-

fault value when an explicit value is not specified for the attribute when you insert a row. For example, 

the following code defines a default constraint for the orderts attribute (representing the order’s time 

stamp):

www.it-ebooks.info




 

CHAPTER 1

 

Background to T-SQL Querying and Programming



 

 25

ALTER TABLE dbo.Orders 

  ADD CONSTRAINT DFT_Orders_orderts 

  DEFAULT(SYSDATETIME()) FOR orderts;

The default expression invokes the SYSDATETIME function, which returns the current date and 

time value. After this default expression is defined, whenever you insert a row in the Orders table 

and do not explicitly specify a value in the orderts attribute, SQL Server will set the attribute value 

to SYSDATETIME.

When you’re done, run the following code for cleanup.

DROP TABLE dbo.Orders, dbo.Employees;



Conclusion

This chapter provided a brief background to T-SQL querying and programming. It presented a theo-

retical background, explaining the strong foundations that T-SQL is based on. It gave an overview of 

the SQL Server architecture and concluded with sections that demonstrated how to use T-SQL to cre-

ate tables and define data integrity. I hope that by now you see that there’s something special about 

SQL, and that it’s not just a language that can be learned as an afterthought. This chapter equipped 

you with fundamental concepts—the actual journey is just about to begin.

www.it-ebooks.info




www.it-ebooks.info



Download 10,93 Mb.

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