If you do not want a column to have a NULL value, then you need to define such constraint on this column specifying that NULL is now not allowed for that column. PRIMARY Key − Uniquely identifies each row/record in a database table.įOREIGN Key − Constrains data based on columns in other tables.ĬHECK Constraint − The CHECK constraint ensures that all values in a column satisfy certain conditions.ĮXCLUSION Constraint − The EXCLUDE constraint ensures that if any two rows are compared on the specified column(s) or expression(s) using the specified operator(s), not all of these comparisons will return TRUE.īy default, a column can hold NULL values. UNIQUE Constraint − Ensures that all values in a column are different. NOT NULL Constraint − Ensures that a column cannot have NULL value. The following are commonly used constraints available in PostgreSQL. For example, a column of type DATE constrains the column to valid dates. Defining a data type for a column is a constraint in itself. Column level constraints are applied only to one column whereas table level constraints are applied to the whole table. This ensures the accuracy and reliability of the data in the database.Ĭonstraints could be column level or table level. These are used to prevent invalid data from being entered into the database. ![]() Constraints are the rules enforced on data columns on table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |