Introduction to SQL
Introduction to SQL
SQL
INTRO, DATA TYPES, COMMANDS, CONSTRAINTS, OPERATORS
What is SQL?
• NOT NULL Constraint − Ensures that a column cannot have NULL value.
• DEFAULT Constraint − Provides a default value for a column when none is
specified.
• UNIQUE Constraint − Ensures that all values in a column are different.
• PRIMARY Key − Uniquely identifies each row/record in a database table.
• FOREIGN Key − Uniquely identifies a row/record in any of the given
database table.
• CHECK Constraint − The CHECK constraint ensures that all the values in a
column satisfies certain conditions.
• INDEX − Used to create and retrieve data from the database very quickly.
Difference between Primary Key Constraint
and Unique Constraint
Primary Key Unique
► Arithmetic Operators
►Logical Operators
►Relational Operators
►Miscellaneous Operators
Arithmetic Operators
The list of arithmetic operators used in SQL
expressions are:
+ Addition
- Subtraction
* Multiplication
/ Division
() Enclosed Operation –
Brackets
Relational Operators
All the relational operators are binary operators i.e. each
operator works on two operands and the result is one of the
values true or false.
List of relational operators:
►= Comparison (Equals to)
►!= , <> Comparison (Not equals to)
►> Greater than
►>= Greater than or equals to
►< Less than
Logical Operators
SQL
►DCL: Data Control Language. Here the user can give some
access permission or take back the permissions already assigned
to users.
DDL
DML
DCL
TCL
DQL