SQL Tutorial - CHECK Constraints

preview_player
Показать описание
Another fantastic SQL Tutorial brought you by BeardedDev.

Tutorials on SQL Querying, SQL Development, Database Administration, Data Analysis and Business Intelligence.

Subscribe to the channel for more fantastic tutorials.

This video contains everything you need to know about CHECK Constraints in SQL Server with working examples.

CHECK Constraints allow us to enforce limits on the data that can be entered in to our tables, in this tutorial we look at preventing entering Sales Values that are less than or equal to 0, after all we don't sell anything for nothing.

CHECK Constraints only prevent values that evaluate to false from being added and we work through another example of how CHECK Constraints do not prevent NULLs from being added if the Data Definition allows.

All Constraints are associated with Tables so if a Table is removed the Constraint is removed too.

There is another example of how we can only add CHECK Constraints to existing columns if the data within that column meets the requirements of the Constraint.

CHECK Constraint Syntax:

CREATE TABLE dbo.Sales
(
Sales_Id INT IDENTITY(1, 1)
, Sales_Date DATE
, Sales_Value DECIMAL(16, 2) [constraint name] CHECK (Sales_Value [greater than] 0)
)

ALTER TABLE [table name]
ADD CONSTRAINT [constraint name] CHECK (column [less than or greater than or equal to] value)

Associated Videos:

Recently Uploaded Videos:
Рекомендации по теме
Комментарии
Автор

Brad: The more #SSIS tutorials, the better. Thank you.

houstonvanhoy
Автор

Can you talk about the SMK and explain how it opens the DMK? I understand opening the DMK with a password but I don't understand how and when the SMK would open the DMK if you chose to encrypt the DMK with the SMK.

VRWarehouse