Sei sulla pagina 1di 17

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : K.Chandra Sekhar
Designation : Associate Lecturer
Branch : DCCP
Institute : Central Institute of Commerce,Tarnaka,
Hyd.
Year/Semester : V Semester
Subject : Relational Database Management System
Subject Code : CCP-505
Topic : Know the components of SQL
Duration : 50 Minutes
Sub-Topic : Explain the commands with syntax
Teaching Aids : PPT,Animation, Photographs
CCP505.34 1
OBJECTIVES

On Completion of this period, you would be


able to know :
• Various Commands covered under DCL of SQL.

• Purpose of DCL Commands.

• Syntax and their brief explanation

CCP505.34 2
RECAP
 Components of SQL
 Various commands of DDL
 Various commands of DML
 Usage of SELECT command

CCP505.34 3
Data control language (DCL)
 How data control is done?
 After definition and manipulation of data using DDL
& DML
 Controlling of data
 Saving or cancelling the changes
 User privilege commands

CCP505.34 4
DCL commands
 COMMIT
 SAVE POINT
 ROLL BACK
 GRANT
 REVOKE

CCP505.34 5
Transaction

 What is transaction?
 Is a logical unit of work
 Changes made to the data base
 Transaction changes can be made permanent

CCP505.34 6
COMMIT
To end a transaction

Make “permanent changes” in the table .

This Command erases all save-points in the transaction and

releases the transaction’s locks.

Syntax

SQL> COMMIT [ work ];

Saves work up to the point till commit is given


CCP505.34 7
SAVEPOINT
Used in conjunction with rollback command to rollback
portions of the current transaction.

Useful in interactive programs, because one can create and


name intermediate steps of a program.

This allows more control over more complex program.

 Syntax

SQL> SAVEPOINT save point_ id;

 Save point_id is any valid character string


CCP505.34 8
What is ROLLBACK?
ROLLBACK Command “undoes” work done in the current
transaction.

Syntax

SQL> ROLLBACK [ work ] [ TO ]

[ SAVE POINT ] [ savepoint_id];

CCP505.34 9
Privilege commands
 What are privilege commands?
 Why are they termed as privilege commands?
 How are they useful?
 Owner of database objects has the Sole authority
over them
 Owner can only allow other users to access
as per his / her discretion

CCP505.34 10
Privilege commands (contd..)

 Permission to use database may be given only


to selected users
 Sharing of data can be possible
 Once granted can be revoked(taken back) by
owner only

CCP505.34 11
Grant command

 Grant command is used to grant privileges


 Allows to view or modify table or all permissions
 Syntax
 SQL>grant privileges on <object name> to < username>
 Displays message “ grant succeeded ”

CCP505.34 12
Revoke commands
 Used to withdraw GRANT permission privilege
 Only user can REVOKE
 Once REVOKED, user can RE GRANT permission
 Syntax
 SQL>Revoke privileges on <object-name>
from <username>;
 Displays message “ revoke succeeded”

CCP505.34 13
Summary :
COMMIT is to end a transaction and make “permanent
all changes”

ROLLBACK Command “undoes” work done in the


current transaction
Save point is used in conjunction with rollback command
to rollback portions of the current transaction.

SAVEPOINT allows more control over more complex


programs

GRANT & REVOKE privilege commands


CCP505.34 14
Quiz

1. Create permission can be given by any user of database


(Yes / No)
 Yes
 No

Answer is : No

CCP505.34 15
Frequently asked questions
1. Explain GRANT & REVOKE commands
2. Explain COMMIT, ROLL BACK, SAVE POINT
commands
3. Explain DCL commands

CCP505.34 16
Assignment
1. Apply DCL commands on vendor_ master data

CCP505.34 17

Potrebbero piacerti anche