Data Control Language
DCL commands are used to GRANT and TAKE BACK authority from any database user.
Here are some commands that come under DCL:
- Grant
- It is used to give user access privileges to a database.
- Example: GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_USER;
- Revoke
- It is used to take back permissions from the user
- Example: REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;
Transaction Control Language
TCL commands can only use with DML commands like INSERT, DELETE and UPDATE only.
These operations are automatically committed in the database that's why they cannot be used while creating tables or dropping them.
Here are some commands that come under TCL:
- COMMIT
- Commit command is used to save all the transactions to the database.
- Syntex:
- COMMIT;
- Example:
- DELETE FROM CUSTOMERS WHERE AGE = 25; COMMIT;
- ROLLBACK
- Rollback command is used to undo transactions that have not already been saved to the database.
- Syntex:
- ROLLBACK;
- Example:
- DELETE FROM CUSTOMERS WHERE AGE = 25; ROLLBACK;
- SAVEPOINT
- It is used to roll the transaction back to a certain point without rolling back the entire transaction.
- Syntex:
- SAVEPOINT SAVEPOINT_NAME;
Comments
Post a Comment