0% found this document useful (0 votes)
137 views

Data Control Language

1) A data control language (DCL) controls access to database data through granting and revoking privileges. 2) Privileges like insert, select, delete, and update can be granted to other users to allow access to objects. 3) Granted privileges can also be revoked to withdraw access from users.

Uploaded by

Sharon Peter
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Data Control Language

1) A data control language (DCL) controls access to database data through granting and revoking privileges. 2) Privileges like insert, select, delete, and update can be granted to other users to allow access to objects. 3) Granted privileges can also be revoked to withdraw access from users.

Uploaded by

Sharon Peter
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Data Control Language

In
Oracle
Data Control Language
• A data control language (DCL) is a syntax used
to control access to data stored in a database.
• Privilege is the right to access another user’s
objects.
• We can grant privileges(insert, select, delete,
update) to others.
• We can also withdraw the privileges.
Grant Privilege
• Privilege such as insert, delete and update can
be granted to other users.
• SYNTAX
Grant privileges on <object_name> to
<user_name>
Example:
Grant select, insert, update on detail to office;
CREATING A TABLE

• sql> create table Product_add


(pro_code number(5) NOT NULL,
pro_name varchar2(20),
pro_price number(7,2),
pro_quantity number(7)
);
Tabel Created.

SQL> Desc PRODUCT_ADD


Name NULL Type
Pro_code NOT NULL number(5)
Pro_name varchar2(20)
Pro_price number(7,2)
Pro_quantity number(7)
Alter Table
• To Add another Column
• SQL> ALTER table PRODUCT_ADD add comm
number(4);
Table Altered.
• TO Modify an existing column
• SQL> ALTER Table PRODUCT_ADD modify
(pro_name varchar2(20) PRIMARY KEY);
• Table Altered.
Drop Table
• Syntax:- DROP TABLE table_name;

– Eg. DROP TABLE product_add;


Data Manipulation Language(DML)
• Select(to query)
• Update(modifying tables)
• Insert(adding new records)
• Delete(remove existing records)

INSERT:-
SQL> Insert into PRODUCT_ADD (prod_code, prod_name) VALUES
(1001, “CYNTHOL”);

SQL> Insert into PRODUCT_ADD values(1002,”LIFEBOY”, 26.70,


10);
SELECT
• SELECT:-
SQL> Select prod_code from PRODUCT_ADD where
prod_name=“CYNTHOL”;
To select particular Field.

SQL> Select * from PRODUCT_ADD;


To select entire table rows and display.
SQL> Select prod_name, prod_code from
PRODUCT_ADD;
To select only two columns of all rows.
UPDATE
• SQL> UPDATE PRODUCT_ADD set
prod_price=30.00 where prod_code=1002;
– To update the price.
DELETE:-
SQL> Delete *from PRODUCT_ADD;
-the above command removes all the rows from the
table PRODUCT_ADD.
Data Control Language (DCL)
• Grant(Create user, provides DB object access)
• Revoke(Revokes the user, revokes DB object
access)
• Commit(Commit the changes)
• Rollback(Nullify the changes)
GRANT:-Syntax
GRANT privileges on <object_name> to
<user_name>
GRANT
• eg. Grant select, insert, delete, update on
PRODUCT_ADD to Purchase_dep;
• REVOKE:- Syntax
REVOKE privileges on <object_name> from
<user_name>;
eg. Revoke select, insert, delete, update on
PRODUCT_ADD from Purchase_dep;
Revoke privilege
• To withdraw the privilege which has been
granted to a user.
• SYNTAX
Revoke privileges on <object name> to
<username>
Example
Revoke insert, delete, update on detail to office;
Commit and Rollback
• Commit: This command will commit the
database for all the transactions(insert, delete
etc.)
SQL>COMMIT;
Rollback: This command will undo the
transactions done in database.
SQL>ROLLBACK;

You might also like