Sahil SQL Queries
Sahil SQL Queries
Sahil SQL Queries
INFORMATION TECHNOLOGY
Sahil
IT,4th
SEM
LAB WORK 1
Query3:
Describe department//department table looks like this
Output:
Query 3: select * from employee where salary between 12221 and 60000
employee
LAB WORK 2
Alter statements(for a table stud)_-these statements are used to alter the
structure of table.
Query-alter table stud add marks number(4)
Query- alter table stud add primary key(rollno)
Query- select dno,count(*) from employee group by dno having count(*)>1 and dno
not in(1)
LAB WORK 3
->Using union ,intersection and minus keywords
Problem-Find out details of the employee who works for dept1 or having
salary more than 5000 using union
Query- select * from employee where dno in(1) union select * from employee where
salary>5000
Problem: Find out details of the employee who works for dept1 or having
salary more than 5000 using intersection
Query: select * from employee where dno=1 intersect select * from employee
where salary>5000;
LAB WORK 4
PROCEDURAL SQL CONCEPTS
output:For input as 3
Using if section
Format:
If
Then
Else if
Then
.
Endif;
An example: To find the greatest to three numbers
declare
a number(2);
b number(2);
c number(2);
begin
a:=:ad;
b:=:bd;
c:=:cd;
if a>b
then
if a>c
then
dbms_output.put_line('a is largest');
else
dbms_output.put_line('c is largest');
end if;
else
if c>b
then
dbms_output.put_line('c is largest');
else
dbms_output.put_line('b is largest');
end if;
end if;
end;
Output:
Output:
Output: