SQL Database
SQL Database
TALK
ABOUT
SQL
A DATABASE LANGUAGE THAT IS
USED IN MOST OF THE DATABASES
IN THE WORLD
@the_master_graduates www.master-graduates.com
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
What is a Database?
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
Example:
Table: Employee.
Field: Emp ID, Emp Name, Date of Birth.
Data: 201456, David, 01/16/1989.
@the_master_graduates
D A I L Y S Q L
DDL Commands:
CREATE; ALTER; DROP; TRUNCATE
@the_master_graduates
D A I L Y S Q L
DML Commands:
INSERT; UPDATE; DELETE
@the_master_graduates
D A I L Y S Q L
TCL Commands:
COMMIT; ROLLBACK; SAVEPOINT
@the_master_graduates
D A I L Y S Q L
DCL Commands:
Grant; Revoke
DQL Commands:
SELECT
@the_master_graduates
D A I L Y S Q L
What is normalization?
What is denormalization?
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
What is join?
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
Unique Index: This indexing does not allow the field to have
duplicate values if the column is unique indexed. Unique
index can be applied automatically when primary key is
defined.
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
What is query?
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
What is a trigger?
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
NOT NULL
UNIQUE
CHECK
DEFAULT
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
What is collation?
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
What is a CLAUSE?
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
Example:
SELECT DISTINCT column1, column2, ...
FROM table_name;
@the_master_graduates
D A I L Y S Q L
Example of BETWEEN:
SELECT * FROM Students
where ROLL_NO BETWEEN 10 AND 50;
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
Example:
SELECT FullName
FROM EmployeeDetails
WHERE EmpId
IN (SELECT EmpId FROM EmployeeSalary WHERE
Salary
BETWEEN 0 AND 10000);
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
What is ENUM?
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
SELECT *
FROM employees
WHERE first_name like ‘Master’;
@the_master_graduates
D A I L Y S Q L
Example:
SELECT *
INTO newtable
FROM oldtable
WHERE condition;
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
Example:
SELECT a.Employee_name, b.Department_name
FROM Employee a, Employee b
WHERE a.Department_ID = b.Department_ID
@the_master_graduates
D A I L Y S Q L
Example:
SELECT b.Department_ID, b.Department_name
FROM Employee a, Department b
WHERE a.Department_id <> b.Department_ID;
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
SELECT user_name
FROM users
WHERE ISNULL(user_phonenumber);
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
What is CTE?
@the_master_graduates
D A I L Y S Q L
For example, consider the set {25, 25, 50, 75, 75, 100}. For
such a set, RANK() will return {1, 1, 3, 4, 4, 6} (note that the
values 2 and 5 are skipped), whereas DENSE_RANK()
will return {1,1,2,3,3,4}.
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates
D A I L Y S Q L
@the_master_graduates