Unit 2
Unit 2
Select all the records present in the table we make use of * character.
• Syntax –
SELECT * FROM table_name;
Example –
SELECT * FROM Students;
1 AAA 60 Pune
2 BBB 70 Gujarat
3 CCC 90 Pune
4 DDD 55 Gujarat
5 EEE 65 Delhi
Syntax –
SELECT col1, col2,….,coln FROM table_name WHERE condition;
Example -
SELECT name_emp, salary FROM Employee where salary<20000;
• Syntax –
Select column_name from table1
union
select column_name from table2; 10
• Example – 20
select DeptNo from Employee 30
union 40
intersect
select Dept_no from Department;
Employee Department
Eno Ename Address Dno Dname Eno
1 Ram Delhi D1 HR 1
2 Varun Pune D2 IT 2
3 Rani Pune D3 Marketing 4
4 Amrit Delhi
Ename
Ram
Varun
Amrit
Ename
Ram
Study
S_id C_id Since
S1 C1 2016
S2 C2 2017
S1 C2 2017
BEGIN
Executable-statements
EXCEPTION
Exception-handling-statements
END;
/
• Roles are names group of privileges that you can assign to users/other
roles.
• A privilege is a right allowing the user to run some particular types of
SQL commands or access the object of another user. Some of the
privileges that are given to users include the rights like connecting to a
database or creating a table. There could also be rights to select the
rows from the users of another table or execute the stored procedure of
another user.