filmov
tv
3. SQL Constraints | Constraints in SQL | What is Unique Constraints | primary key in sql

Показать описание
SQL Constraints | Constraints in SQL | What is Unique Constraints | primary key in sql
Join SQL WhatsApp group to solve your SQL queries:
What is constraints in SQL? 00:01
Constraints are the rules enforced on the data columns of a table.
These are used to limit the type of data that can go into a table.
This ensures the accuracy and reliability of the data in the database.
Constraints can be specified when a table is created with the CREATE TABLE statement or you can use the ALTER TABLE statement to create constraints even after the table is created.
Types of Constraints in SQL: 00:40
1. Not Null
2. Default
3. Unique
4. Primary Key
5. Foreign Key
6. Check
7. Index
1. NOT NULL Constraints 01:02
By default, a column can hold NULL values.
If you do not want a column to have a NULL value, then you need to define such a constraint on this column specifying that NULL is now not allowed for that column.
2. DEFAULT Constraints 02:00
The DEFAULT constraint provides a default value to a column when the INSERT INTO statement does not provide a specific value.
3. UNIQUE Constraints 02:55
The UNIQUE Constraint prevents two records from having identical values in a column. In the CUSTOMERS table.
for example, you might want to prevent two or more people from having an identical age.
4. PRIMARY KEY Constraints 04:23
A primary key is a field in a table which uniquely identifies each row/record in a database table. Primary keys must contain unique values.
A primary key column cannot have NULL values.
A table can have only one primary key, which may consist of single or multiple fields. When multiple fields are used as a primary key, they are called a composite key.
5. FOREIGN KEY Constraints 05:40
A foreign key is a key used to link two tables together. This is sometimes also called as a referencing key.
A Foreign Key is a column or a combination of columns whose values match a Primary Key in a different table.
6. CHECK Constraints 06:50
The CHECK Constraint enables a condition to check the value being entered into a record.
If the condition evaluates to false, the record violates the constraint and isn't entered the table.
7. INDEX Constraints 07:58
The INDEX is used to create and retrieve data from the database very quickly.
An Index can be created by using a single or group of columns in a table.
When the index is created, it is assigned a ROWID for each row before it sorts out the data.
Proper indexes are good for performance in large databases, but you need to be careful while creating an index.
A Selection of fields depends on what you are using in your SQL queries.
Join SQL WhatsApp group to solve your SQL queries:
Join this channel to get access to perks:
📌 Follow us on Instagram :
Thanks :
Fox Tech Academy
WhatsApp : +91 8252348796
#tcs #accenture #infosys #techmahindra #interview
Join SQL WhatsApp group to solve your SQL queries:
What is constraints in SQL? 00:01
Constraints are the rules enforced on the data columns of a table.
These are used to limit the type of data that can go into a table.
This ensures the accuracy and reliability of the data in the database.
Constraints can be specified when a table is created with the CREATE TABLE statement or you can use the ALTER TABLE statement to create constraints even after the table is created.
Types of Constraints in SQL: 00:40
1. Not Null
2. Default
3. Unique
4. Primary Key
5. Foreign Key
6. Check
7. Index
1. NOT NULL Constraints 01:02
By default, a column can hold NULL values.
If you do not want a column to have a NULL value, then you need to define such a constraint on this column specifying that NULL is now not allowed for that column.
2. DEFAULT Constraints 02:00
The DEFAULT constraint provides a default value to a column when the INSERT INTO statement does not provide a specific value.
3. UNIQUE Constraints 02:55
The UNIQUE Constraint prevents two records from having identical values in a column. In the CUSTOMERS table.
for example, you might want to prevent two or more people from having an identical age.
4. PRIMARY KEY Constraints 04:23
A primary key is a field in a table which uniquely identifies each row/record in a database table. Primary keys must contain unique values.
A primary key column cannot have NULL values.
A table can have only one primary key, which may consist of single or multiple fields. When multiple fields are used as a primary key, they are called a composite key.
5. FOREIGN KEY Constraints 05:40
A foreign key is a key used to link two tables together. This is sometimes also called as a referencing key.
A Foreign Key is a column or a combination of columns whose values match a Primary Key in a different table.
6. CHECK Constraints 06:50
The CHECK Constraint enables a condition to check the value being entered into a record.
If the condition evaluates to false, the record violates the constraint and isn't entered the table.
7. INDEX Constraints 07:58
The INDEX is used to create and retrieve data from the database very quickly.
An Index can be created by using a single or group of columns in a table.
When the index is created, it is assigned a ROWID for each row before it sorts out the data.
Proper indexes are good for performance in large databases, but you need to be careful while creating an index.
A Selection of fields depends on what you are using in your SQL queries.
Join SQL WhatsApp group to solve your SQL queries:
Join this channel to get access to perks:
📌 Follow us on Instagram :
Thanks :
Fox Tech Academy
WhatsApp : +91 8252348796
#tcs #accenture #infosys #techmahindra #interview