DBMS Lab Manual
DBMS Lab Manual
Prepared By
A. KALYAN KUMAR
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
L T P C
II Year – II Semester
0 0 3 1.5
DATABASE MANAGEMENT SYSTEMS LAB
Course Objectives:
This Course will enable students to
• Populate and query a database using SQL DDL/DML Commands
• Declare and enforce integrity constraints on a database
• Writing Queries using advanced concepts of SQL
• Programming PL/SQL including procedures, functions, cursors and triggers
Course Outcomes:
At the end of the course the student will be able to:
• Utilize SQL to execute queries for creating database and performing data
manipulation operations
• Examine integrity constraints to build efficient databases
• Apply Queries using Advanced Concepts of SQL
• Build PL/SQL programs including stored procedures, functions, cursors and triggers
List of Exercises:
1. Creation, altering and droping of tables and inserting rows into a table (use constraints
while creating tables) examples using SELECT command.
2. Queries (along with sub Queries) using ANY, ALL, IN, EXISTS, NOTEXISTS,
UNION, INTERSET, Constraints. Example:- Select the roll number and name of the
student who secured fourth rank in the class.
3. Queries using Aggregate functions (COUNT, SUM, AVG, MAX and MIN), GROUP
BY, HAVING and Creation and dropping of Views.
4. Queries using Conversion functions (to_char, to_number and to_date), string
functions (Concatenation, lpad, rpad, ltrim, rtrim, lower, upper, initcap, length, substr
and instr), date functions (Sysdate, next_day, add_months, last_day, months_between,
least, greatest, trunc, round, to_char, to_date)
5.
i. Create a simple PL/SQL program which includes declaration section, executable
section and exception –Handling section (Ex. Student marks can be selected
from the table and printed for those who secured first class and an exception can
be raised if no records were found)
ii. Insert data into student table and use COMMIT, ROLLBACK and
SAVEPOINT in PL/SQL block.
6. Develop a program that includes the features NESTED IF, CASE and CASE
expression. The program can be extended using the NULLIF and COALESCE
functions.
7. Program development using WHILE LOOPS, numeric FOR LOOPS, nested loops
using ERROR Handling, BUILT –IN Exceptions, USE defined Exceptions, RAISE-
APPLICATION ERROR.
8. Programs development using creation of procedures, passing parameters IN and OUT
of PROCEDURES.
9. Program development using creation of stored functions, invoke functions in SQL
Statements and write complex functions.
10. Develop programs using features parameters in a CURSOR, FOR
UPDATE CURSOR, WHERE CURRENT of clause and CURSOR variables.
11. Develop Programs using BEFORE and AFTER Triggers, Row and Statement
Triggers and INSTEAD OF Triggers
12. Create a table and perform the search operation on table using indexing and non-
indexing techniques.
3. Write a PL/SQL Code using Cursors, Exceptions and Composite Data Types
Table altered.
Q3) Add new columns height as number, weight as real to existing table sailors
SQL> alter table sailors add (height number(3),weight real);
Table altered.
Table altered.
SQL> desc sailors;
Name Null? Type
----------------------------------------- -------- -------------
SID NOT NULL NUMBER(3)
SNAME VARCHAR2(20)
AGE NUMBER(3)
HEIGHT NUMBER(3)
WEIGHT FLOAT(63)
Q5) Modify the data types of name and weight in sailors table.
Table altered.
Table altered.
Table altered.
Table created.
Table altered.
Table altered.
Q11) Add unique key constraint on bname in boats table
Table altered.
Q12) Add a check constraint on color which accepts either red, green or blue color in boats
table.
Table altered.
CONSTRAINT_NAME C
------------------------------ -
PKY P
UNI U
CHK C
Q14) Drop a constraint whose name is chk from the table boats.
Table altered.
CONSTRAINT_NAME C
------------------------------ -
PKY P
UNI U
Q16) Add foreign key constraints on sid,bin in reserves referencing tables sailors and
boats.
Table altered.
Table altered.
CONSTRAINT_NAME C
------------------------------ -
FKY R
FKY2 R
Table renamed.
Table dropped.
1 row created.
SQL> /
Enter value for id: 103
Enter value for name: ranger
Enter value for color: blue
old 1: insert into boats values (&id,'&name','&color')
new 1: insert into boats values (103,'ranger','blue')
1 row created.
Q21) Remove all the rows in the table boats (by using ‘truncate’).
Table truncated.
SQL> select * from boats;
no rows selected
SQL> commit;
SQL> exit;
Table created.
1 row created.
SQL> /
Enter value for id: 33
Enter value for name: sridhar
Enter value for mob: 9966778855
old 1: insert into student values(&id,'&name',&mob)
new 1: insert into student values(33,'sridhar',9966778855)
1 row created.
1 row created.
1 row created.
Q4) create a table std_mob (sid,mob_no) from student table with records also.
Table created.
5 rows created.
SID MOB_NO
---------- ----------
11 9988776655
22 9977886655
33 9966778855
44
55 9988667755
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
SNAME
---------------
Dustin
Brutus
Lubber
Andy
Rusty
Horatio
Zorba
Horatio
Art
Bob
10 rows selected.
SNAME
---------------
Andy
Art
Bob
Brutus
Dustin
Horatio
Lubber
Rusty
Zorba
9 rows selected.
SNAME RATING
--------------- ----------
Dustin 7
Horatio 7
Q11) Find sailor names and ratings whose rating is greater than 7.
SNAME RATING
--------------- ----------
Lubber 8
Andy 8
Rusty 10
Zorba 10
Horatio 9
Q12) Find sailor names and rating whose rating is less than 6 using not.
SNAME RATING
--------------- ----------
Brutus 1
Art 3
Bob 3
Q13) Find sailor names and rating whose rating is between 3 and 7.
SNAME RATING
--------------- ----------
Dustin 7
Horatio 7
Art 3
Bob 3
Q14) Find sailor names and rating whose name starts with B.
SNAME RATING
--------------- ----------
Brutus 1
Bob 3
Q15) Find sailor names and rating whose name ends with y.
SNAME RATING
--------------- ----------
Andy 8
Rusty 10
Q15) Find sailor names and rating whose name contains the substring or.
SNAME RATING
--------------- ----------
Horatio 7
Zorba 10
Horatio 9
Q16) Find sailor names and rating whose name contains exactly 3 characters.
SQL> select sname,rating from sailors where sname like '_ _ _';
SNAME RATING
--------------- ----------
Art 3
Bob 3
Q17) Find sailor names and rating whose name does not contains letter r.
SQL> select sname,rating from sailors where sname not like '%r%';
SNAME RATING
--------------- ----------
Dustin 7
Andy 8
Rusty 10
Bob 3
Q18) Diasplay all sailor names and rating whose name does not contains letter r in
increasing order of rating
SQL> select sname,rating from sailors where sname not like '%r%' order by rating;
SNAME RATING
--------------- ----------
Bob 3
Dustin 7
Andy 8
Rusty 10
Q18) Display sailor names and rating whose name does not contains letter r and display in
decreasing order of rating.
SQL> select sname,rating from sailors where sname not like '%r%' order by rating desc;
SNAME RATING
--------------- ----------
Rusty 10
Andy 8
Dustin 7
Bob 3
Q19) Display sailor names and rating whose rating is 8 in alphabetical order.
SNAME RATING
--------------- ----------
Andy 8
Lubber 8
Q20) select sailor name and rating whose rating is either greater than 7 or rating less than
3
SNAME RATING
--------------- ----------
Brutus 1
Lubber 8
Andy 8
Rusty 10
Zorba 10
Horatio 9
6 rows selected.
Q21) create table boats(bid,bname,color) with bid as primary key.
Table created.
1 row created.
1 row created.
Q23) Create table reserves(sid,bid,day) where sid,bid,day as primary key and sid,did as
foreign key referencing the tables sailors and boats respectively.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
SQL> insert into reserves (sid, bid, day)
2 values (31, 104, '11/dec/98');
1 row created.
SQL> insert into reserves (sid, bid, day)
2 values (64, 101, '9/may/98');
1 row created.
1 row created.
Q25) Find the sailor names who have reserved atleast one boat.
SNAME BID
--------------- ----------
Dustin 101
Dustin 102
Dustin 103
Dustin 104
Lubber 102
Lubber 103
Lubber 104
Horatio 101
Horatio 102
Horatio 103
10 rows selected.
Q26) Find the sailors name who have reserved boat number 103.
SQL> select a.sname,b.bid from sailors a, reserves b where a.sid=b.sid and b.bid=103;
SNAME BID
--------------- ----------
Dustin 103
Lubber 103
Horatio 103
Q27) Find the sailors name who have reserved boat ‘Marine’.
SQL> select a.sname,b.bid from sailors a, reserves b,boats c where a.sid=b.sid and b.bid=c.bid
and c.bname='Marine';
SNAME BID
--------------- ----------
Dustin 104
Lubber 104
Q28) Find the sailors who have reserved red color boat.
SQL> select a.sname, a.rating, c.bname from sailors a, reserves b,boats c where a.sid=b.sid and
b.bid=c.bid and c.color='red'
SNAME RATING BNAME
--------------- ---------- ----------
Dustin 7 Interlake
Dustin 7 Marine
Lubber 8 Interlake
Lubber 8 Marine
Horatio 7 Interlake
Q29) Find the sailors who have reserved either red or blue color boat.
Q30) Find the sailor names who have reserved both red and blue color boats.
Q31) Find the sailor names who have reserved red color boat but not blue color boat.
SQL> (select a.sname from sailors a, reserves b,boats c
2 where a.sid=b.sid and b.bid=c.bid and c.color='red')
3 minus
4 (select a.sname from sailors a, reserves b,boats c
5 where a.sid=b.sid and b.bid=c.bid and c.color='blue');
SNAME
---------------
Lubber
Q32) Find all the sailor names who reserved either red or blue color boats.
SQL> (select a.sname from sailors a, reserves b,boats c
2 where a.sid=b.sid and b.bid=c.bid and c.color='red')
3 union
4 (select a.sname from sailors a, reserves b,boats c
5 where a.sid=b.sid and b.bid=c.bid and c.color='blue');
SNAME
---------------
Dustin
Horatio
Lubber
Q33) Find all the sailor names(with duplicates) who reserved either red or blue color boats.
SQL> (select a.sname from sailors a, reserves b,boats c
2 where a.sid=b.sid and b.bid=c.bid and c.color='red')
3 union all
4 (select a.sname from sailors a, reserves b,boats c
5 where a.sid=b.sid and b.bid=c.bid and c.color='blue');
SNAME
---------------
Dustin
Dustin
Lubber
Lubber
Horatio
Dustin
Horatio
7 rows selected.
Q34) Find the sailors who have reserved atleast one boat using nested query.
SQL> select * from sailors where sid in (select sid from reserves);
Q35) Find the sailors who have not reserved atleast one boat using nested query.
SQL> select * from sailors where sid not in (select sid from reserves);
6 rows selected.
Q36) Find the sailors whose who have reserved boat number 103 using nested query.
Q37) Find the sailors who have not reserved red color boat.
7 rows selected.
Q38) Find the sailor names who reserved boat number 103
SNAME
---------------
Dustin
Lubber
Horatio
Q39) Find the sailor names who do not reserved boat number 103
SNAME
---------------
Brutus
Andy
Rusty
Horatio
Zorba
Art
Bob
7 rows selected.
Q40) Find the sailor names who reserved all the boats.
SNAME
---------------
Dustin
3 rows updated.
2 rows updated.
4 rows updated.
Q46) Modify name to marine and color to pink for boats whose id>=103
Table created.
SQL> /
Enter value for id: 66
Enter value for name: praneeth
Enter value for sal: 32000
old 1: insert into employee values(&id,'&name',&sal)
new 1: insert into employee values(66,'praneeth',32000)
1 row created.
SQL> /
Enter value for id: 55
Enter value for name: rajesh
Enter value for sal: 33000
old 1: insert into employee values(&id,'&name',&sal)
new 1: insert into employee values(55,'rajesh',33000)
1 row created.
1 row deleted.
no rows selected
SQL> commit;
Commit complete.
SQL> exit;
Program 2
Aim: Queries (along with sub Queries) using ANY, ALL, IN, EXISTS,
NOTEXISTS, UNION, INTERSECT, Constraints.
Find the sailor names who have reserved atleast one boat.
SNAME BID
--------------- ----------
Dustin 101
Dustin 102
Dustin 103
Dustin 104
Lubber 102
Lubber 103
Lubber 104
Horatio 101
Horatio 102
Horatio 103
10 rows selected.
Find the sailors who have reserved atleast one boat using nested query.
SQL> select * from sailors where sid in (select sid from reserves);
Find the sailors who have not reserved atleast one boat using nested query.
SQL> select * from sailors where sid not in (select sid from reserves);
6 rows selected.
Find the sailors name who have reserved boat number 103.
SQL> select a.sname,b.bid from sailors a, reserves b where a.sid=b.sid and b.bid=103;
SNAME BID
--------------- ----------
Dustin 103
Lubber 103
Horatio 103
Find the sailors whose who have reserved boat number 103 using nested query.
SQL> select * from sailors where sid in
2 (select sid from reserves where bid=103);
Find the sailor names who reserved boat number 103 using exists
SNAME
---------------
Dustin
Lubber
Horatio
SQL> select a.sname,b.bid from sailors a, reserves b,boats c where a.sid=b.sid and b.bid=c.bid
and c.bname='Marine';
SNAME BID
--------------- ----------
Dustin 104
Lubber 104
SQL> select a.sname, a.rating, c.bname from sailors a, reserves b,boats c where a.sid=b.sid and
b.bid=c.bid and c.color='red'
SNAME RATING BNAME
--------------- ---------- ----------
Dustin 7 Interlake
Dustin 7 Marine
Lubber 8 Interlake
Lubber 8 Marine
Horatio 7 Interlake
Q. Find the names of sailors who have not reserved boat 103.
SQL> select sname from sailors where sid not in (select sid from reserves where bid=103);
SNAME
Brutus
Andy
John
Horatio
Zorba
Art
Bob
Q. Find the sailors name and rating where rating is greater than bob and Andy using all.
SQL>
Select sname, rating from sailors where rating>all(select rating from sailors where sname like
‘Bob’ or sname like ‘Andy’);
SNAME RATING
Rusty 10
Zorba 10
Horatio 9
Q. find the sailors name and rating whose rating is greater than Bob and Andy using any.
SQL> select sname, rating from sailors where not rating <=any(select rating from sailors where
sname=’Bob’ or sname=’Andy’);
SNAME RATING
Rusty 10
Zorba 10
Horatio 9
Q. Find the sailors ids,names who have reserved either red or the blue color boat using union
SQL> select sname from sailors s,reserves r,boats b where b.color like ‘red’ and b.bid=r.bid and
r.sid=s.sid union(select sname from sailors s,reserves r,boats b where b.color like ‘blue’ and
b.bid=r.bid and r.sid=s.sid);
SNAME
Dustin
Lubber
Q.find the sailors names who reserved both red and blue color boats using intersect
SQL>select sname from sailors s,reserves r,boats b where b.color=’red’ and b.bid=r.bid and
r.sid=s.sid
Intersect (select sname from sailors s,reserves r,boats b where b.color=’blue’ and b.bid=r.bid and
r.sid=s.sid);
SNAME
Dustin
3. Views
Table created.
1 row created.
SQL> /
Enter value for id: 66
Enter value for name: praneeth
Enter value for sal: 26005.25
Enter value for age: 28
old 1: insert into employee values(&id,'&name',&sal,&age)
new 1: insert into employee values(66,'praneeth',26005.25,28)
1 row created.
View created.
1 row created.
ENAME AGE
--------------- ----------
sudhakar 32
praneeth 28
suresh 28
1 row updated.
ENAME AGE
--------------- ----------
sudha 32
praneeth 28
suresh 28
1 row deleted.
ENAME AGE
--------------- ----------
sudha 32
suresh 28
1 row created.
1 row updated.
1 row deleted.
View dropped.
SQL> commit;
SQL> exit;
Table created.
1 row created.
SQL> /
Enter value for id: 66
Enter value for name: praneeth
Enter value for sal: 26005.25
Enter value for age: 28
old 1: insert into employee values(&id,'&name',&sal,&age)
new 1: insert into employee values(66,'praneeth',26005.25,28)
1 row created.
View created.
1 row created.
ENAME AGE
--------------- ----------
sudhakar 32
praneeth 28
suresh 28
1 row updated.
ENAME AGE
--------------- ----------
sudha 32
praneeth 28
suresh 28
1 row deleted.
ENAME AGE
--------------- ----------
sudha 32
suresh 28
Q6)Insert a new record in view emp and verify it in table employee
1 row created.
1 row updated.
1 row deleted.
View dropped.
SQL> commit;
SQL> exit;
Program 4
Converts the first letter of each word to upper case and remaining letters to
Initcap
lowercase
Concat Joins values together you are limited to two arguments with concat
LENGTH('SQLFUNCTIONS')
----------------------
12
Number Functions:
Date Functions:
SYSDATE is a pseudo column that returns the current date and time. When we select sysdate it
will display in a dummy table called DUAL. Oracle date range between 1st jan 4712 BC and 31st
Dec 4712 AD.
Months_between It returns the numeric value. Finds the no. of months between
date1 and date2, result may be positive or negative.
Add_months It returns the date datatype. Adds n number of calendar months to
date, n must be an integer and it can be negative
Last_day It returns the date datatype. Date of the
Next_day It returns the date datatype. Date of the next specified day of the
week following date1, char may be number representing a day, or a
character
MONTHS_BETWEEN(SYSDATE,HIREDATE)
--------------------------------
354.728983
352.632208
352.567692
351.212854
345.374144
14 rows selected.
Sunday 1
Monday 2
Tuesday 3
Wednesday 4
Thursday 5
Friday 6
Saturday 7
Conversion Functions:
To_char(number | date,[‘fmt’] Converts numbers or date to character format fmt
To_number(char) Converts char, which contains a number to a NUBER
To_date Converts the char value representing date, into a date value
according to fmt specified. If fmt is omitted, format is DD-
MM-YYYY
SQL> select to_char(3000, '$9999.99') from dual;
TO_CHAR(3
---------
$3000.00
‘
EXERCISE-5
1 56 76 86
2 45 55 65
23 24 44 34
3 10 20 30
4 50 60 70
Program:
declare
sno marks.sid%type;
m1 marks.flat%type;
m2 marks.java%type;
m3 marks.dbms%type;
avg number(10,4);
begin
sno:='&sno';
avg:=(m1+m2+m3)/3;
if(avg>=70) then
dbms_output.put_line('First Class');
dbms_output.put_line('Second Class');
dbms_output.put_line('Third Class');
else
dbms_output.put_line('Fail');
end if;
exception
end;
Output: 5a.sql
old 8: sno:='&sno';
new 8: sno:='1';
First Class
new 8: sno:='5';
ii. AIM: Insert data into student table and use COMMIT, ROLLBACK
and SAVEPOINT in PL/SQL block.
SQL> create table student s(sno number(5), sname varchar(10), address varchar(10),
2 phone_number number(10));
Output: Table Created
savepoint a;
rollback to a;
commit;
Output: 5b.sql
1 row created.
1 row created.
Savepoint created.
1 row created.
1 row created.
Rollback complete.
1 row created.
1 row created.
Commit complete.
Commit complete.
5 lubber JK 12345
6 george HP 12346
10 abhi AP 12350
Exercise-6
Aim:Develop a program that includes the features NESTED IF, CASE and
CASE expression. The program can be extended using the NULLIF and
COALESCE functions.
Program:
declare
fname varchar2(10);
lname varchar2(10);
ch number;
res varchar2(10);
res1 varchar2(10);
begin
fname:='&fname';
lname:='&lname';
ch:=&ch;
when 1 then
res:=nullif(fname,lname);
dbms_output.put_line('res is:'||res);
dbms_output.put_line('lname is null');
dbms_output.put_line('fname is null');
else
when 2 then
res:=COALESCE(fname,lname);
res1:=COALESCE(lname,fname);
dbms_output.put_line('res is:'||res);
if res=lname then
dbms_output.put_line('Fname is null');
dbms_output.put_line('Lname is null');
else
end if;
else
end case;
end;
Output: 6.sql
old 8: fname:='&fname';
new 8: fname:='hello';
Enter value for lname: hello
old 9: lname:='&lname';
new 9: lname:='hello';
res is:
old 8: fname:='&fname';
new 8: fname:='hello';
old 9: lname:='&lname';
new 9: lname:='world';
res is:hello
old 8: fname:='&fname';
new 8: fname:='hello';
old 9: lname:='&lname';
new 9: lname:='';
res is:hello
Lname is null
old 8: fname:='&fname';
new 8: fname:='';
old 9: lname:='&lname';
new 9: lname:='';
res is:
declare
i number(5);
begin
dbms_output.put_line(i);
END LOOP;
END;
Output: for.sql
10
declare
a number:=10;
begin
dbms_output.put_line('value of a:'||a);
a:=a+1;
END LOOP;
END;
Output:
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
declare
x number(5);
d number(5);
q number(5);
begin
x:=÷nt;
d:=&divisor;
if((d!=0)) then
q:=x/d;
else
raise zero_divide;
end if;
exception
end;
Output: raiseex.sql
old 6: x:=÷nt;
new 6: x:=4;
old 7: d:=&divisor;
new 7: d:=2;
the quotient is 2
old 6: x:=÷nt;
new 6: x:=4;
old 7: d:=&divisor;
new 7: d:=0;
Proc_cal.sql
declare
x number(10);
y number(10);
begin
x:=&x;
if(x>0) then
fact1(x,y);
end if;
end;
Proc.sql
i integer;
begin
f:=1;
for i in 1 .. n loop
f:=f*i;
end loop;
end;
/
Output:
old 5: x:=&x;
new 5: x:=5;
Functions:
Drop function:
We can easily drop the function
Syntax:
Drop function <function_name>;
Program:
AIM:Program development using creation of stored functions,invoke
functions in SQL statements and write complex functions
l number;
b number;
area number;
begin
area:=rectangle(l,b);
end;
/
Exercise-10
Cursors:
Oracle creates a private memory area, known as the context area. Cursor will points to that
contex area(private area or temperory memory area)
Befor submitting result to the user each query will processor at cursor
Types of cursors:
1.Implict cursor
2. Explict cursors
1.Implict cursor: It can be created by oracle engine and managed by oracle engine
Properties:
➢ %Isopen
➢ %Found
➢ %NotFound
➢ %RowCount
By default Each and every property begin with SQL
sql%Isopen
sql%Found
sql%NotFound
sql%RowCount
Explict Cursor:
These cursors can be done by the user and managed by the user
Explicit cursor is more efficient when comapared with implicit cursor,because it requires
less space
Fetch:
All the data it will available in the cursor
The record ptr will points only single row every time it will fetch each record/row by
using loops
Syntax:
Fetch <cursor_name> INTO variables;
Close cursor:
When all records are processed then close the cursor
Syntax:
Close< cursor_name>;
Program:
create an employ table and retrieve the name of employ whose salary is Greater than
25000 by PL/SQL
Declare
emp_rec varchar(30);
cursor emp_cur is
Begin
Open emp_cur;
Loop
dbms_output.put_line(emp_rec);
end loop;
close emp_cur;
end;
Output:
Deepika
Ramesh
sai
Advanced cursors
PARAMETER CURSORS
An explicit cursor may accept a list of parameters. Each time you open the cursor, you can pass
different arguments to the cursor, which results in different result sets.
Syntax:
To open the cursor with parameter we you use the following syntax:
Syntax:
Open <cursorname>(parameter_valu);
FOR UPDATE CURSOR:
FOR UPDATE statement allows you to lock the records in the cursor. The record locks are
released when the next commit or rollback statement is issued.
Syntax
Cursor <cursor_name> is
Select stmt
Program
declare
cursor c1 is select ename from employee where dno=10 for update of salary NOWAIT;
begin
Program:
Exercise-11
Syntax:
Create or replace trigger [trigger_name]
[before | after]
{insert | update | delete}
on [table_name]
[for each row]
[trigger_body]
on office
for each row
when(new.id>0)
begin
dbms_output.put_line('trigger fried');
end;
Output:
Trigger is created
Table created
Insert :
Trigger fried
1 row is inserted
Updated:
Trigger fried
1 row updated
Delete:
1 row deleted
Exercise-12
Example:
Create index id1 on emp;
Single-Column Indexes
A single-column index is created based on only one table column. The basic syntax is as follows.
Syntax:
example:
create unique index id3 on emp (empid);
Composite Indexes
A composite index is an index on two or more columns of a table. Its basic syntax is as follows.
CREATE INDEX index_name
on table_name (column1, column2);
DROP INDEX
An index can be dropped using SQL DROP command