Postgres - Constraint and Check Constraint in PostgreSQL
The constraints are used to describe the rules for the data columns in a table. If there is any destruction between the constraints and the data action, the action is terminated immediately. The constraints make sure the dependability and the correctness of the data in the database.
In this section, we are going to discuss all the PostgreSQL Constraints.
The constraints can be further divided as column level or table level where the table level constraints are used for the whole table, and the Column level constraints are used only for one column.
Where we use the constraints?
The constraints are most commonly used in below areas:
Once it is created, it can be added to a table, and we can also disable it temporarily.
To individual columns, we can use the column constraints.
When we are creating a table with the help of creating table command, we can also declare the constraints
SQL can discard any value which interrupts the well-defined criteria.
All the information related to the constraints is kept in the data dictionary.
For one or more columns, we can use the table constraints.
All the constraint is allocated a name.
NOT NULL Constraint
In not-null constraint, a column can hold the Null values by default. If we don't want a column to have a NULL value, then we need to explain such constraint on this column state that NULL is now not acceptable for that particular column. It is always created as a column constraint, and it represents unknown data but it doesn't mean that the data would be null.
CHECK Constraint
In PostgreSQL, the Check constraint can be defined by a separate name. It is used to control the value of columns being inserted. It allows us to verify a condition that the value being stored into a record. If the statement is false, then the data disrupts the constraint and is not saved into the table.
Unique Constraint
The unique constraint is used to maintain the individuality of the values that we store into a field or a column of the table. It is compatible with a group of column constraints or column constraints and a table constraint.
When we are using the unique constraint, an index on one or more columns generate automatically. If we add two different null values into a column in different rows, but it does not interrupt the specification of the UNIQUE constraint.
Primary key Constraint
It is a field in a table that individually identifies each row or the record in a database table, and it contains a unique value. A primary key does not hold any null value. And for this, we can also say that the primary key is a collection of the unique and not-null constraint of a table.
It is used to identify each record in a database table distinctively. Here we can contain further unique columns, but we have only one primary key in a database table, and that includes single or multiple fields. It is the most crucial key while creating the database tables, and it could be a unique ID. It can be signified for one column or group of columns.
The working of the primary key is similar to a unique constraint. Still, the significant difference between them is one table can have only one primary key; however, the table can have one or more unique and not-null constraints.
Foreign key Constraint
It is a group of columns with values that depend on the primary key benefits from another table. It is used to have the value in a column or group of columns that must be displayed in the same column or combination of columns in another table.
In PostgreSQL, the foreign key's values as parallel to actual values of the primary key in the other table; that's why it is also known as Referential integrity Constraint.
EXCLUSION Constraint
It is used to make sure that any two rows are linked on the specified columns or statements using the defined operators. In any case, one of these operator evaluations will return null or false.
Dropping Constraints
If we want to delete a constraint, then we should remember the name of the constraints as it is easier for us to drop the constraints directly by its name. Otherwise, we will require to identify the system-generated name.
#postgres , #postgresql, #postgresql tutorial, #postgres tutorial, #what is postgresql, #what is postgres, #history of postgresql
#postgressql, #postgresql tutorial for beginners, #postgresql course, postgres, postgresql,postgresql tutorial, postgres tutorial, what is postgresql, what is postgres, history of postgresql, postgressql, postgresql tutorial for beginners, postgresql course
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Postgres - Constraint and Check Constraint in PostgreSQL», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.