Syntax of CONSTRAINTS in SQL-
CREATE TABLEย <table_name>(<column_name1><datatype><constraint>,โฆโฆโฆโฆโฆโฆโฆโฆโฆ<column_nameN><datatype> <constraint>);
CONSTRAINTS | Usage |
NOT NULL | To ensure that column canโt have a NULL value |
UNIQUE | To ensure that all vales in a column are different |
PRIMARY KEY | To ensure unique identification of each row in a table.It is a combinaton of NOT NULL & UNIQUE . |
FOREIGN KEY | To prevent action that would destroy links between tables. |
CHECK | To ensure that the values in a column meet a specific condition. |
DEFAULT | To set a default value for a colum if no value is specified. |
CREATE INDEX | To create and retrieve data from the database quickly. |
Saraswat World Changed status to publish June 8, 2023
Leave a Reply