7.Data Manipulation Using SQL
7.Data Manipulation Using SQL
DDL
DML
Introduction to data manipulation with SQL
• The name SQL is derived from Structured Query Language.
• SQL is now the standard language for commercial relational
DBMSs.
Inserting tuples
INSERT INTO S VALUES
(‘S1’,’GEMUNU’,20,’COLOMBO’)
Removing Duplications
SELECT DISTINCT ENAME FROM EMPLOYEE;
Not null
SELECT * FROM WHERE IS NOT NULL;
Statements
• An ALTER command must be used to change the schema of
EMPLOYEE, after the “create table DEPARTMENT,” to add a
FK.
SELECT ENAME
FROM EMPLOYEES
WHERE ENAME LIKE ‘_A%’;
FROM tables
[WHERE condition]
[GROUP BY attributes]
[HAVING condition]
[ORDER BY attributes]
Retrieval with ordering
Select employees number and city where employees in Kandy, in
descending order of the status.
SELECT S#, CITY
FROM
WHERE CITY =‘KANDY’
ORDER BY CITY DESC;