Q. Define the various SQL Constraints.


Answer =

Constraints are the rules enforced on data or columns on a table. These are used to restrict the values that can be inserted in a table. This ensures data accuracy and reliability in the database.

Following are the most commonly used constraints available in SQL:

(a) NOT NULL Constraint: Ensures that a column cannot have NULL value.

(b) DEFAULT Constraint: Provides a default value for a column when no value is specified.

(c) UNIQUE Constraint: Ensures that all values in a column are unique. There should not be any redundant value in a column which is being restricted.

(d) PRIMARY Key: Uniquely identifies each row/record in a database table.

(e) FOREIGN Key: Uniquely identifies a row/record in any other database table.

(f) CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy certain conditions. For example, to restrict the salary column that it should contain salary more than 10,000.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post