0% found this document useful (0 votes)
25 views31 pages

DBMS New

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views31 pages

DBMS New

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

INDEX

1. Lab Prerequisute

2. Lab Manual Objective

3. Outcome

4. Program List

5. Basic Concepts of Programs

6. Value Addition

7. Appendix
PROGRAM LIST

1. Write SQL queries to implement DDL commands.


2. Write SQL queries to implement DML commands.
3. Write SQL queries to implement TCL commands.
4. Write SQL queries to implement Keys constraints.
5. Write SQL queries to implement Joins.
6. Write SQL queries to implement Views.
7. Write SQL queries to SELECT data using SET UNION ,INTERSECTION and
MINUS operations.
8. Write SQL queries using AGGREGATE functions.
9. Write SQL queries to implement Nested queries.
10. Write a PL/SQL code block to find factorial of a number.
11. Write a PL/SQL code block to implement Indexes.
12. Write a PL/SQL code block to implement Procedures.
13. Write a PL/SQL code block to implement Triggers.
BASIC CONCEPTS OF PROGRAMS

1. Write SQL queries to implement DDL commands.

It is used to communicate with database. DDL is used to:


o Create an object
o Alter the structure of an object
o To drop the object created.

The commands used are:


 Create
 Alter
 Drop
 Truncate
 Rename

1. COMMAND NAME: CREATE


COMMAND DESCRIPTION: CREATE command is used to create objects in the database.

2. COMMAND NAME: DROP


COMMAND DESCRIPTION: DROP command is used to delete the object from the database.

3. COMMAND NAME: TRUNCATE


COMMAND DESCRIPTION: TRUNCATE command is used to remove all the records from the
table

4. COMMAND NAME: ALTER


COMMAND DESCRIPTION: ALTER command is used to alter the structure of database

5. COMMAND NAME: RENAME


COMMAND DESCRIPTION: RENAME command is used to rename the objects.
2. Write SQL queries to implement DML commands.

DML (DATA MANIPULATION LANGUAGE)


 SELECT
 INSERT
 DELETE
 UPDATE

1. COMMAND NAME: INSERT


COMMAND DESCRIPTION: INSERT command is used to Insert objects in the
database.

2. COMMAND NAME: SELECT


COMMAND DESCRIPTION: SELECT command is used to SELECT the object from the
database.

3. COMMAND NAME: UPDATE


COMMAND DESCRIPTION: UPDATE command is used to UPDATE the records from
the table

4. COMMAND NAME: DELETE


COMMAND DESCRIPTION: DELETE command is used to DELETE the Records form
the table
3. Write SQL queries to implement TCL

TCL (TRANSACTION CONTROL LANGUAGE)


 COMMIT
 ROLL BACK
 SAVE POINT

1. COMMAND NAME: COMMIT


COMMAND DESCRIPTION: COMMIT command is used to save the Records.

2. COMMAND NAME: ROLLBACK


COMMAND DESCRIPTION: ROLL BACK command is used to undo the
Records.

3. COMMAND NAME: SAVE POINT


COMMAND DESCRIPTION: SAVE POINT command is used to undo the
Records in a particular transaction.
4. Write SQL queries to implement Keys constraints.
Constraints are part of the table definition that limits and restriction on the value entered into
its columns.

TYPES OF CONSTRAINTS:

1) Primary key : A PRIMARY KEY constraint is a unique identifier for a row within a
database table. Every table should have a primary key constraint to uniquely identify
each row and only one primary key constraint can be created for each table. The
primary key constraints are used to enforce entity integrity.

2) Foreign key/references : A FOREIGN KEY constraint prevents any actions that would
destroy link between tables with the corresponding data values. A foreign key in one table
points to a primary key in another table. Foreign keys prevent actions that would leave rows
with foreign key values when there are no primary keys with that value. The foreign key
constraints are used to enforce referential integrity.

3) Check : A CHECK constraint is used to limit the values that can be placed in a column.
The check constraints are used to enforce domain integrity.

4) Unique : A UNIQUE constraint enforces the uniqueness of the values in a set of columns,
so no duplicate values are entered. The unique key constraints are used to enforce entity
integrity as the primary key constraints.

5) Not null : A NOT NULL constraint enforces that the column will not accept null values.
The not null constraints are used to enforce domain integrity, as the check constraints.

6) Default : The DEFAULT constraint provides a default value to a column when


the INSERT INTO statement does not provide a specific value.

CONSTRAINTS CAN BE CREATED IN THREE WAYS:

1) Column level constraints


2) Table level constraints
3) Using DDL statements-alter table command
5. Write SQL queries to implement Joins.

SQL joins are used to query data from two or more tables, based on a relationship between
certain columns in these tables.

SQL COMMANDS

COMMAND NAME: INNER JOIN


COMMAND DESCRIPTION: The INNER JOIN keyword return rows when there is at least one
match in both tables.

COMMAND NAME LEFT JOIN


COMMAND DESCRIPTION: The LEFT JOIN keyword returns all rows from the left table
(table_name1), even if there are no matches in the right table (table_name2).

COMMAND NAME : RIGHT JOIN


COMMAND DESCRIPTION: The RIGHT JOIN keyword Return all rows from the right table
(table_name2), even if there are no matches in the left table (table_name1).

COMMAND NAME : FULL JOIN


COMMAND DESCRIPTION: The FULL JOIN keyword return rows when there is a match in one
of the tables.
6.Write SQL queries to implement

Views Helps to encapsulate complex query and make it reusable.

• Provides user security on each view - it depends on your data policy security.
• Using view to convert units - if you have a financial data in US currency, you can create
view to convert them into Euro for viewing in Euro currency.

SQL COMMANDS

1. COMMAND NAME: CREATE VIEW


COMMAND DESCRIPTION: CREATE VIEW command is used to define a view.

2. COMMAND NAME: INSERT IN VIEW


COMMAND DESCRIPTION: INSERT command is used to insert a new row into the view.

3. COMMAND NAME: DELETE IN VIEW


COMMAND DESCRIPTION: DELETE command is used to delete a row from the view.

4. COMMAND NAME: UPDATE OF VIEW


COMMAND DESCRIPTION: UPDATE command is used to change a value in a tuple
without changing all values in the tuple.

5. COMMAND NAME: DROP OF VIEW


COMMAND DESCRIPTION: DROP command is used to drop the view table
7.Write SQL queries to SELECT data using SET
INTERSECTION and MINUS operations.

UNION

It returns a union of two select statements. It is returning unique (distinct) values of them.

SELECT * FROM table1


UNION
SELECT * FROM table2

MINUS

MINUS (also known as EXCEPT) returns the difference between the first and second
SELECT statement. It is the one where we need to be careful which statement will be put
first, cause we will get only those results that are in the first SELECT statement and not in the
second.

SELECT * FROM table1


MINUS
SELECT * FROM table2;

INTERSECT

INTERSECT is opposite from MINUS as it returns us the results that are both to be found in
first and second SELECT statement.

SELECT * FROM table1


INTERSECT
SELECT * FROM table2;
8. Write SQL queries using AGGREGATE functions.

An aggregate function is a function where the values of multiple rows are grouped together
as input on certain criteria to form a single value of more significant meaning or
measurement such as a set, a bag or a list.

The functions include:

o count() - counts a number of rows


o sum() - compute sum
o avg() - compute average
o min() - compute minimum
o max() - compute maximum
9.Write SQL queries to implement Nested

Nested Query can have more than one level of nesting in one single query. A SQL nested
query is a SELECT query that is nested inside a SELECT, UPDATE, INSERT, or DELETE
SQL query.

SQL COMMANDS

1. COMMAND NAME: SELECT


COMMAND DESCRIPTION: SELECT command is used to select records from the table.

2. COMMAND NAME: WHERE


COMMAND DESCRIPTION: WHERE command is used to identify particular elements.

3. COMMAND NAME: HAVING


COMMAND DESCRIPTION: HAVING command is used to identify particular elements.

4. COMMAND NAME: MIN (SAL)


COMMAND DESCRIPTION: MIN (SAL) command is used to find minimum salary.
10Write a PL/SQL code block to find factorial of a

declare
n number;
i number;
f number:=1;
begin
n:=&n;
for i in 1..n
loop
f:=f*i;
end loop;
dbms_output.put_line(n||'! = '||f);
end;

Output:
Enter value for n: 5
old 6: n:=&n;
new 6: n:=5;
5! = 120
PL/SQL procedure successfully completed.
11.Write a PL/SQL code block to implement

, . . . ,column_nameN)
[COMPUTE STATISTICS];
A collection is an ordered group of elements having the same data type. Each element is
identified by a unique subscript that represents its position in the collection.

PL/SQL provides three collection types:

 Index-by tables or Associative array

 Nested table

 Variable-size array or Varray

An index-by table (also called an associative array) is a set of key-value pairs. Each key
is unique and is used to locate the corresponding value. The key can be either an integer
or a string.

Syntax for creating an INDEX in Oracle SQL / PLSQL is:

CREATE [UNIQUE] INDEX index_name


ON TABLE table_name (column_name1,column_name2
12. Write a PL/SQL code block to implement Procedures.

A procedure is created with the CREATE OR REPLACE PROCEDURE statement. The


simplified syntax for the CREATE OR REPLACE PROCEDURE statement is as follows:

CREATE [OR REPLACE] PROCEDURE


procedure_name [(parameter_name [IN | OUT | IN OUT]
Where,
type [, ...])]
{IS| procedure-name specifies the name of the procedure.
AS} [OR REPLACE] option allows modifying an existing procedure.
BEGIN
 The optional parameter list contains name, mode and types of the parameters. IN
represents that value will be passed from outside and OUT represents that this
parameter will be used to return a value outside of the procedure.

 procedure-body contains the executable part.

 The AS keyword is used instead of the IS keyword for creating a standalone


procedure.
13. Write a PL/SQL code block to implement Triggers.

Trigger automatically associated with DML statement, when DML statement execute
trigger implicitly execute.

We can create trigger using the CREATE TRIGGER statement. If trigger activated,
implicitly fire DML statement and if trigger deactivated can't fire.

PL/SQL trigger define using CREATE TRIGGER statement.

CREATE [OR REPLACE] TRIGGER


trigger_name BEFORE | AFTER
[INSERT, UPDATE, DELETE [COLUMN NAME..]
ON table_name

Referencing [ OLD AS OLD | NEW AS NEW ]


FOR EACH ROW | FOR EACH STATEMENT [ WHEN Condition ]

DECLARE
[declaration_section
variable
declarations;
constant
declarations;
]

BEGIN
[executable_section
PL/SQL execute/subprogram body
]

EXCEPTION
[exception_section
PL/SQL Exception block
]
VALUE ADDITION

IMPLEMENTATION OF CURSORS

CURSOR PROGRAM FOR ELECTRICITY BILL CALCULATION:

SQL> create table bill(name varchar2(10), address varchar2(20), city varchar2(20), unit
number(10));
Table created.

SQL> insert into bill values('&name','&addess','&city','&unit');

Enter value for name: yuva

Enter value for addess: srivi

Enter value for city: srivilliputur

Enter value for unit: 100

old 1: insert into bill values('&name','&addess','&city','&unit')

new 1: insert into bill values('yuva','srivi','srivilliputur','100')

1 row created.

SQL> /

Enter value for name: nithya

Enter value for addess: Lakshmi nagar

Enter value for city: sivakasi

Enter value for unit: 200

old 1: insert into bill values('&name','&addess','&city','&unit')

new 1: insert into bill values('nithya','Lakshmi nagar','sivakasi','200')


1 row created.
Enter value for name: maya

Enter value for addess: housing board

Enter value for city: sivakasi

Enter value for unit: 300

old 1: insert into bill values('&name','&addess','&city','&unit')

new 1: insert into bill values('maya','housing board','sivakasi','300')

1 row created.

SQL> /

Enter value for name: jeeva

Enter value for addess: RRR nagar

Enter value for city: sivaganagai

Enter value for unit: 400

old 1: insert into bill values('&name','&addess','&city','&unit')

new 1: insert into bill values('jeeva','RRR nagar','sivaganagai','400')

1 row created.

SQL> select * from bill;

NAME ADDRESS CITY UNIT


yuva srivi srivilliputur 100

nithya Lakshmi nagar sivakasi 200

maya housing board sivakasi 300


SQL> declare

2 cursor c is select * from bill;

3 b bill %ROWTYPE;

4 begin

5 open c;

6 dbms_output.put_line('Name Address city Unit Amount');

7 loop

8 fetch c into b;

9 if(c % notfound) then

10 exit;

11 else

12 if(b.unit<=100) then

13 dbms_output.put_line(b.name||' '||b.address||' '||b.city||' '||b.unit||' '||b.uni t*1);

14 elsif(b.unit>100 and b.unit<=200) then

15 dbms_output.put_line(b.name||' '||b.address||' '||b.city||' '||b.unit||' '||b. unit*2);

16 elsif(b.unit>200 and b.unit<=300) then

17 dbms_output.put_line(b.name||' '||b.address||' '||b.city||' '||b.unit||' '||b. unit*3);

18 elsif(b.unit>300 and b.unit<=400) then

19 dbms_output.put_line(b.name||' '||b.address||' '||b.city||' '||b.unit||' '||b.unit*

4);

20 else

21 dbms_output.put_line(b.name||' '||b.address||' '||b.city||' '||b.unit||' '||b.unit*

5);

22 end if;
23 end if;

24 end loop;

25 close c;

26 end;

27 /

Name Address city Unit Amount

yuva srivi srivilliputur 100 100

nithya Lakshmi nagar sivakasi 200 400

maya housing board sivakasi 300 900

jeeva RRR nagar sivaganagai 400 1600

PL/SQL procedure successfully completed.


M.I.E.T.

APPENDIX

1. Write SQL queries to implement DDL commands.

DDL commands used are:


o Create
o Alter
o Drop
o Truncate

QUERY: 01 Write a query to create a table employee with empno, ename, designation, and
salary.

Syntax for creating a table:

SQL: CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 <DATATYPE> (SIZE), COLUMN


NAME.1 <DATATYPE> (SIZE)...............................);

SQL>CREATE TABLE EMP (EMPNO NUMBER (4),


ENAME VARCHAR2 (10),
DESIGNATIN VARCHAR2 (10),
SALARY NUMBER (8,2));
Table created.

QUERY: 02 Write a query to display the column name and datatype of the table employee.

Syntax for describe the table:

SQL: DESC <TABLE NAME>;

SQL> DESC EMP;

Name Null? Type

EMPNO NUMBER(4)
ENAME VARCHAR2(10)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)

D.B.M.S. PROGRAM
M.I.E.T.

ALTER & MODIFICATION ON TABLE

QUERY: 03 Write a Query to Alter the column EMPNO NUMBER (4) TO EMPNO
NUMBER(6).

Syntax for Alter & Modify on a Single Column:

SQL > ALTER <TABLE NAME> MODIFY <COLUMN NAME> <DATATYPE> (SIZE);

SQL>ALTER TABLE EMP MODIFY EMPNO NUMBER (6);


Table altered.

SQL> DESC EMP;

Name Null? Type

EMPNO NUMBER(6)
ENAME VARCHAR2(10)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)

QUERY: 04 Write a Query to Alter the table employee with multiple columns (EMPNO,
ENAME.)

Syntax for alter table with multiple column:

SQL > ALTER <TABLE NAME> MODIFY <COLUMN NAME1> <DATATYPE> (SIZE),
MODIFY <COLUMN NAME2> <DATATYPE> (SIZE)
………………………………………….;

SQL>ALTER TABLE EMP MODIFY (EMPNO NUMBER (7), ENAME


VARCHAR2(12));
Table altered.

SQL> DESC EMP;

Name Null? Type

EMPNO NUMBER(7)
ENAME VARCHAR2(12)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2);

D.B.M.S. PROGRAM
M.I.E.T.

QUERY: 05 Write a query to add a new column in to employee

Syntax for add a new column:

SQL> ALTER TABLE <TABLE NAME> ADD (<COLUMN NAME> <DATA TYPE>
<SIZE>);

SQL> ALTER TABLE EMP ADD QUALIFICATION VARCHAR2(6);


Table altered.
SQL> DESC EMP;
Name Null? Type

EMPNO NUMBER(7)
ENAME VARCHAR2(12)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)
QUALIFICATION VARCHAR2(6)

QUERY: 06 Write a query to add multiple columns in to employee

Syntax for add a new column:

SQL> ALTER TABLE <TABLE NAME> ADD (<COLUMN NAME1> <DATA TYPE>
<SIZE>,(<COLUMN NAME2> <DATA TYPE> <SIZE>,
………………………………………………………………);

SQL>ALTER TABLE EMP ADD (DOB DATE, DOJ DATE);


Table altered

SQL> DESC EMP;

Name Null? Type

EMPNO NUMBER(7)
ENAME VARCHAR2(12)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)
QUALIFICATION VARCHAR2(6)
DOB DATE
DOJ DATE

REMOVE / DROP

D.B.M.S. PROGRAM
M.I.E.T.

QUERY: 07 Write a query to drop a column from an existing table employee

Syntax for add a new column:

SQL> ALTER TABLE <TABLE NAME> DROP COLUMN <COLUMN NAME>;

SQL> ALTER TABLE EMP DROP COLUMN DOJ;


Table altered.

SQL> DESC EMP;

Name Null? Type

EMPNO NUMBER(7)
ENAME VARCHAR2(12)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)
QUALIFICATION VARCHAR2(6)
DOB DATE

QUERY: 08 Write a query to drop multiple columns from employee

Syntax for add a new column:

SQL> ALTER TABLE <TABLE NAME> DROP <COLUMN NAME1>,<COLUMN


NAME2>,…...........................................;

SQL> ALTER TABLE EMP DROP (DOB, QUALIFICATION);


Table altered.

SQL> DESC EMP;

Name Null? Type

EMPNO NUMBER(7)
ENAME VARCHAR2(12)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)

REMOVE

QUERY: 09 Write a query to rename table emp to employee

D.B.M.S. PROGRAM
M.I.E.T.

Syntax for add a new column:

SQL> ALTER TABLE RENAME <OLD NAM E> TO <NEW NAME>

SQL> ALTER TABLE EMP RENAME EMP TO EMPLOYEE;

SQL> DESC EMP;

Name Null? Type

EMPNO NUMBER(7)
ENAME VARCHAR2(12)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)

2. Write SQL queries to implement DML commands.

DML (DATA MANIPULATION LANGUAGE)


 SELECT
 INSERT

D.B.M.S. PROGRAM
M.I.E.T.

 DELETE
 UPDATE

INSERT

QUERY: 01 Write a query to insert the records in to employee.

Syntax for Insert Records in to a table:

SQL :> INSERT INTO <TABLE NAME> VALUES< VAL1, ‘VAL2’,…..);

INSERT A RECORD FROM AN EXISTING TABLE:

SQL>INSERT INTO EMP VALUES(101,'NAGARAJAN','LECTURER',15000);


1 row created.

SELECT

QUERY: 02 Write a query to display the records from employee.

Syntax for select Records from the table:

SQL> SELECT * FROM <TABLE NAME>;

DISPLAY THE EMP TABLE:

SQL> SELECT * FROM EMP;

EMPNO ENAME DESIGNATION SALARY

101 NAGARAJAN LECTURER 15000

INSERT A RECORD USING SUBSITUTION METHOD

QUERY: 03 . Write a query to insert the records in to employee using substitution


method.

Syntax for Insert Records into the table:

D.B.M.S. PROGRAM
M.I.E.T.

SQL :> INSERT INTO <TABLE NAME> VALUES< ‘&column name’, ‘&column
name 2’,…..);

SQL> INSERT INTO EMP


VALUES(&EMPNO,'&ENAME','&DESIGNATIN','&SALARY');

Enter value for empno: 102


Enter value for ename: SARAVANAN
Enter value for designatin: LECTURER
Enter value for salary: 15000
old 1: INSERT INTO EMP
VALUES(&EMPNO,'&ENAME','&DESIGNATIN','&SALARY')
new 1: INSERT INTO EMP VALUES(102,'SARAVANAN','LECTURER','15000')
1 row created.

SQL> /
Enter value for empno: 103
Enter value for ename: PANNERSELVAM
Enter value for designatin: ASST. PROF
Enter value for salary: 20000
old 1: INSERT INTO EMP
VALUES(&EMPNO,'&ENAME','&DESIGNATIN','&SALARY')
new 1: INSERT INTO EMP VALUES(103,'PANNERSELVAM','ASST.
PROF','20000')
1 row created.

SQL> /

Enter value for empno: 104


Enter value for ename: CHINNI
Enter value for designatin: HOD, PROF
Enter value for salary: 45000
old 1: INSERT INTO EMP
VALUES(&EMPNO,'&ENAME','&DESIGNATIN','&SALARY')
new 1: INSERT INTO EMP VALUES(104,'CHINNI','HOD, PROF','45000')
1 row created.

SQL> SELECT * FROM EMP;


EMPNO ENAME DESIGNATION SALARY

101 NAGARAJAN LECTURER 15000


102 SARAVANAN LECTURER 15000
103 PANNERSELVAM ASST. PROF 20000

D.B.M.S. PROGRAM
M.I.E.T.

104 CHINNI HOD, PROF 45000

UPDATE

QUERY: 04 Write a query to update the records from employee.

Syntax for update Records from the table:

SQL> UPDATE <<TABLE NAME> SET <COLUMNANE>=<VALUE> WHERE


<COLUMN NAME=<VALUE>;

SQL> UPDATE EMP SET SALARY=16000 WHERE EMPNO=101;


1 row updated.

SQL> SELECT * FROM EMP;

EMPNO ENAME DESIGNATION SALARY

101 NAGARAJAN LECTURER 16000


102 SARAVANAN LECTURER 15000
103 PANNERSELVAM ASST. PROF 20000
104 CHINNI HOD, PROF 45000

UPDATE MULTIPLE COLUMNS

QUERY: 05 Write a query to update multiple records from employee.

Syntax for update multiple Records from the table:

SQL> UPDATE <<TABLE NAME> SET <COLUMNANE>=<VALUE> WHERE


<COLUMN NAME=<VALUE>;

SQL>UPDATE EMP SET SALARY = 16000, DESIGNATIN='ASST. PROF'


WHERE EMPNO=102;
1 row updated.

SQL> SELECT * FROM EMP;

EMPNO ENAME DESIGNATOIN SALARY

101 NAGARAJAN LECTURER 16000


102 SARAVANAN ASST. PROF 16000

D.B.M.S. PROGRAM
M.I.E.T.

103 PANNERSELVAM ASST. PROF 20000


104 CHINNI HOD, PROF 45000

DELETE

QUERY: 06 . Write a query to delete records from employee.

Syntax for delete Records from the table:

SQL> DELETE <TABLE NAME> WHERE <COLUMN NAME>=<VALUE>;

SQL> DELETE EMP WHERE EMPNO=103;


1 row deleted.

SQL> SELECT * FROM EMP;


EMPNO ENAME DESIGNATOIN SALARY

101 NAGARAJAN LECTURER 16000


102 SARAVANAN ASST. PROF 16000
104 CHINNI HOD, PROF 45000

3. Write SQL queries to implement TCL commands.

TCL (TRANSACTION CONTROL LANGUAGE)


 COMMIT
 ROLL BACK
 SAVE POINT

D.B.M.S. PROGRAM
M.I.E.T.

SAVEPOINT:

QUERY: 01 Write a query to implement the save point.

Syntax for save point:

SQL> SAVEPOINT <SAVE POINT NAME>;

SQL> SAVEPOINT S1;


Savepoint created.

SQL> SELECT * FROM EMP;

EMPNO ENAME DESIGNATION SALARY


-
101 NAGARAJAN LECTURER 16000
102 SARAVANAN ASST. PROF 16000
104 CHINNI HOD, PROF 45000

SQL> INSERT INTO EMP VALUES(105,'PARTHASAR','STUDENT',100);


1 row created.

SQL> SELECT * FROM EMP;


EMPNO ENAME DESIGNATION SALARY

105 PARTHASAR STUDENT 100


101 NAGARAJAN LECTURER 16000
102 SARAVANAN ASST. PROF 16000
104 CHINNI HOD, PROF 45000

ROLL BACK

QUERY: 02 Write a query to implement the Rollback.

D.B.M.S. PROGRAM
M.I.E.T.

Syntax for save point:

SQL> ROLL BACK <SAVE POINT NAME>;

SQL> ROLL BACK S1;


Rollback complete.

SQL> SELECT * FROM EMP;

EMPNO ENAME DESIGNATIN SALARY

101 NAGARAJAN LECTURER 16000


102 SARAVANAN ASST. PROF 16000
103 PANNERSELVAM ASST. PROF 20000
104 CHINNI HOD, PROF 45000

COMMIT
QUERY: 03 Write a query to implement the Rollback.

Syntax for commit:

SQL> COMMIT;

SQL> COMMIT;

Commit complete.

4. Write SQL queries to implement Keys constraints.

Constraints are part of the table definition that limits and restriction on the value entered into
its columns.

TYPES OF CONSTRAINTS:

D.B.M.S. PROGRAM

You might also like