Dbms Module 4
Dbms Module 4
Operator Returns
UNION ALL All rows selected by either query, including all duplicates
MINUS All distinct rows selected by the first query but not the second
Syntax
SELECT * FROM table_name1
UNION
SELECT * FROM table_name2;
must be same.
Syntax:
SELECT * FROM table1
INTERSECT
SELECT * FROM table2;
order by default.
Syntax:
SELECT * FROM table1
MINUS
SELECT * FROM table2;
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 8- 30
Example SELECT * FROM First
MINUS
First table SELECT * FROM Second;
ID Name
1 abhi Result set table
2 adam
Item1 Com1 2 10 20
Item2 Com2 3 25 75
Item3 Com1 2 30 60
Item4 Com3 5 10 50
Item5 Com2 2 20 40
Item6 Cpm1 3 25 75
Item8 Com1 3 10 30
Item9 Com2 2 25 50
Output: 10
Output: 25
Syntax:
AVG()
or
AVG( [ALL|DISTINCT] expression )
Output: 67.00
Output: 10
SQL:
INSERT Command
UPDATE Command
DELETE Command
Example:
INSERT INTO Student VALUES (104, ’Anmol’, 89, 19)
101 Ramesh 92 20
201 Jatin 83 19
Suppose, you want to insert a new record into the student table.
For this, you have to write the following DML INSERT
command:
UPDATE Student
SET User_Name = 'beinghuman'
WHERE Student_Id = '3'
Student_Id FirstName LastName User_Name
EXAMPLE :-
Example:
SELECT DISTINCT(Job) FROM Employee;
1 Jack
2 Harry
3 Jackson
4 Stephan
5 David
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 8- 66
UNION ALL
1 Jack
2 Harry
3 Jackson
3 Jackson
4 Stephan
5 David
ID NAME
3 Jackson
1 Jack
2 Harry
SELECT column_names
FROM table_name
WHERE column_name IS NULL;
SELECT column_names
FROM table_name
WHERE column_name IS NOT NULL;
Item1 Com1 2 10 20
Item2 Com2 3 25 75
Item3 Com1 2 30 60
Item4 Com3 5 10 50
Item6 Cpm1 3 25 75
Item8 Com1 3 10 30
Item9 Com2 2 25 50
Item6
Item8
Item9
SELECT columns
FROM table1
INNER JOIN table2 ON condition
Emp_name Salary
Hari 10000
Om 7000
Jay 5000
Smith NULL
Om Mumbai 7000
Student Marks
Awards
id employee_id award_date
1 1 2022-04-01
2 3 2022-05-01
id name
1 Augustine Hammond
3 Cassy Delafoy
Trigger Classification
Classification based on Timing:
• BEFORE Trigger
• AFTER Trigger
AS
{SQL_Statements}
E.FNAME=D.DEPENDENT_NAME