By 25/02/2016 1 Comments

What Is CHECK Constraint In SQL?

  • SQL CHECK constraint limits the range of a value which is placed in a database table column.
  • SQL CHECK constraint can be applied/added on single column level as well as table level.
  • SQL CHECK constraint uses different conditions (>, < ==) etc to enforce¬†a table column to accept only values according to that condition.
  • SQL CHECK constraint validates the table column.

Example: MySQL

CREATE TABLE country
(
country_id INT NOT NULL,
country_name VARCHAR(200) NOT NULL,
country_location VARCHAR(200),
country_zipcode INT(60),
CHECK (country_id>0)
);

Example: SQL Server, Oracle, MS Access

CREATE TABLE country
(
country_id int NOT NULL CHECK (country_id>0),
country_name varchar(200) NOT NULL,
country_location varchar(200),
country_zipcode int
)

Note: 

  • In above examples a CHECK constraint is added on country_id column in country table.






Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .