1. • Paper Name -- Database System
• Staff -- Ms. S. Jamuna M.Sc., M.phil.,
• Class -- II Year
• Semester -- IV
• Unit -- III
• Topic -- Structured Query Language(SQL)
4. Create Query
• Command Name: CREATE
• Command Description: Create Command is used to create the
object in database.
• Query: create table table_name(attributes);
• Example:
create table Student(STDNO int(4),STDNAME varchar(10),DEPT
varchar(10));
5. Insert Query
• Command Name: INSERT
• Command Description: Insert command is used to insert the values
in the database.
• Query: insert into table_name values(attributes);
• Example:
insert into Student (&STDNO,&STDNAME,&DEPT) values
(101,’Aathira’,’Info Tech’),(102,’Aathvik’,’Maths’);
6. Update Query
• Command Name: UPDATE
• Command Description: Update command is used to update the
records from the table.
• Query: update table_name set attribute where attribute(value);
• Example:
update Student set DEPT= ‘English’ where
STUDNO=101;
7. Alter Query
• Command Name: ALTER
• Command Description: Alter command is used to alter the
Structure of database.
• Query: alter table_name add (values);
• Example:
alter Student add YEAR
8. Select Query
• Command Name: SELECT
• Command Description: Select command is used to select the
object from the database.
• Query: select * from table_name;
• Example:
select *from Student;
9. Delete Query
• Command Name: DELETE
• Command Description: Delete Command is used to delete the
records from the table.
• Query: Delete table_name where attributes or values;
• Example:
delete STUDENT where STDNO=102;
10. Drop Query
• Command Name: DROP
• Command Description: Drop command is used to delete the
objects from the database.
• Query: drop table table_name;
• Example:
drop table STUDENT;
11. Truncate Query
• Command Name: TRUNCATE
• Command Description: Truncate is used to remove all the
records from the table.
• Query: truncate table table_name;
• Example:
truncate table Student;
12. Rename Query
• Command Name: RENAME
• Command Description: Rename command is used to change
the table name.
• Query: alter table table_name rename new table_name;
• Example:
alter table Student rename STUD;
14. Union Query
• Command Name: Union
• Command Description: This command is used to combine the
records of multiple tables having the same structure. Avoid
duplicates.
• Query: select attribute from table1 union select attribute from
table2;
• Example:
select name, dept from stud1 union select name, dept
from stud2;
15. Union All Query
• Command Name: Union all
• Command Description: This command is used to combine the
records of multiple tables having the same structure but including
duplicates.
• Query: select attribute from table1 union all select attribute from
table2;
• Example:
select name, dept from stud1 union all select name, dept from
stud2;
16. Intersect Query
• Command Name: INTERSECT
• Command Description: This command is used to give the
common records of multiple table having the same structure.
• Query: select attribute from table1 intersect select attribute
from table2;
• Example:
select name from stud1 intersect select name from stud2;
18. Average Query
• Command Name: AVERAGE
• Command Description: This command is used to return the
average value of N ignoring null values.
• Query: select avg(attribute) result from table_name;
• Example:
select avg(salary) result from Employee;
19. Minimum Query
• Command Name: MINIMUM
• Command Description: This command is used to return the
minimum value of the expression.
• Query: select min(attribute) result from table_name;
• Example:
select min(salary) result from Employee;
20. Maximum Query
• Command Name: MAXIMUM
• Command Description: This command is used to returns
maximum values of the expressions.
• Query: select max(attribute) from table_name;
• Example:
Select max(salary) from Employee;
21. Count Query
• Command Name: COUNT
• Command Description: This command is used to return the
number of rows whose expressions is not null.
• Query: select count(attributes) result from table_name where
values;
• Example:
select count (Salary) result from Employee where
empno=345;
22. Count(*) Query
• Command Name: COUNT(*)
• Command Description: This command is used to return the
number of rows in the table including the duplicate and null
values.
• Query: select count(*)result from table_name;
• Example:
select count(*) result from employee;
23. Sum Query
• Command Name: SUM
• Command Description: This command is used to return the
sum of values of N.
• Query: select sum(attribute) result from table_name;
• Example:
select sum(salary) result from Employee;
25. Natural Join Query
• Command Name: NATRUAL JOIN
• Command Description: This command is used to combine
certain selections and a cartesian product into a one
operations.
• Query: select table1.attribute from table1 join table2
on(table1.attribute=table2.attribute)
• Example:
select emp1.name,dept from EMP join emp2
on(emp1.name=emp2.name)
26. Left Outer Join Query
• Command Name: LEFT OUTER JOIN
• Command Description: This Command is used to return all rows
from the left.
• Query: select table1.attribute from table1 left outer join table2
on(table1.attribute=table2.attribute)
• Example:
select emp1.name,dept from EMP left outer join emp2
on(emp1.name=emp2.name)
27. Right Outer Join Query
• Command Name: RIGHT OUTER JOIN
• Command Description: This command is used to return the all rows
from the right.
• Query: select table1.attribute from table1 right outer join table2
on(table1.attribute=table2.attribute)
• Example:
select emp1.name,dept from EMP right outer join emp2
on(emp1.name=emp2.name)
28. Full Outer Join Query
• Command Name: FULL OUTER JOIN
• Command Description: This command is used to returns all rows
from the left and right.
• Query: select table1.attribute from table1 full outer join table2
on(table1.attribute=table2.attribute)
• Example:
select emp1.name,dept from EMP full outer join emp2
on(emp1.name=emp2.name)