In this post I want to discuss about DRL, TCL and DCL statements.
DRL ::
DRL means Data Retrieval Language. This will be used for the retrieval of the data from the database.
In order to see the data present in the database, we will use DRL statement. We have only one DRL
statement.
SELECT is the only DRL statement in SQL.
SELECT ::
Select statement is used to see the data present in the database. Syntax for writing this statement is,
SELECT col_list FROM tab_name;
If we want to see the data present in all the columns of the table,then we can use following syntax,
SELECT * FROM tab_name;
Ex ::
To check data present in all the columns of Emp table,
SELECT * FROM Emp;
To check data present in specific columns of the table, we will use first syntax.
Ex ::
SELECT empno,ename FROM Emp;
In this I am just checking data present in empno and ename columns.
TCL ::
TCL means Transaction Control Language. These statements are used to control the transactions made by the DML statements to the database. Any change which is made to the database by a DML statement will be called as a transaction. We need to control these transactions made by DML statements.
Whatever change made to the database by a DML statement will not reside permanently in the database, unless auto commit option enabled in the session. Those changes will reside in temporary memory. So, we need to handle these changes.
TCL statements will be used for this purpose. We have 3 TCL statements available.
1 COMMIT
2 ROLLBACK
3 SAVEPOINT
1. COMMIT ::
Commit will be used to make the changes made by DML statements permanent to the database. After performing DML operations , if we issue commit then those changes will be made permanent to the database. If Auto commit option for session is enabled, then this is not required as commit takes place automatically.
Note : DDL statements will carry implicit commit. So, if we issue DDL statement against the database, after doing some DML operations , then due to implicit commit of DDL, previous DML statements also will be commited as commit of DDL applies for the session till that point.
COMMIT;
2. ROLLBACK ::
Rollback will be used to discard the changes made by DML statements to the database. If auto commit option enabled in the session , then there is no use with Rollback statements as transactions will be commited automatically.
So, If we give Rollback then any pending changes to the database which are made by DML statements will be discarded.
ROLLBACK;
3. SAVEPOINT ::
To Rollback the changes to a certain transaction point, we will use SAVEPOINT. I will discuss about this in future posts while discussing PL/SQL.
DCL ::
DCL means Data Control Language. These statements are used for controlling the access to database objects for users. Generally these statements will be used by DBA people to control the access of users to the database.
We have 2 DCL statements available in SQL.
1. GRANT
2. REVOKE
1. GRANT ::
Grant will be used for giving permissions on the database to users. Using this we can give any type of permissions to the users on the database.
For ex if we want to give Select permission on all the database tables to a user,
GRANT SELECT ANY TABLE TO user_name;
If we want to give select permission on specific table then
GRANT SELECT ON tab_name TO user_name;
If we want to give Create table permission then,
GRANT CREATE TABLE TO user_name;
Like this we can give any privilege to the users on the database.
2. REVOKE ::
Revoke will be used to remove the permissions which are granted previously to the users on the database.
IF we want to remove permissions given in the above statements, then we can use following statements.
REVOKE SELECT ANY TABLE FROM user_name;
REVOKE SELECT ON tab_name FROM user_name;
REVOKE CREATE TABLE FROM user_name.
Like this using DCL statements we can control the access of users to the database.
Difference Between DELETE and TRUNCATE ::
---> Delete is DML where as Truncate is DDL.
---> Delete requires transaction control as it is DML. Truncate does not require transaction control as it is
DDL
---> If we remove data using DML, then we can get back it by giving Rollback (if commit not done). But
we cannot get the data removed by Truncate (auto commit).
---> Using Delete we can remove specific rows (using where clause) or total rows also. But using Truncate
we can remove entire rows only. (we cannot use where clause with truncate).
---> Truncate is faster than Delete.
Whatever change made to the database by a DML statement will not reside permanently in the database, unless auto commit option enabled in the session. Those changes will reside in temporary memory. So, we need to handle these changes.
TCL statements will be used for this purpose. We have 3 TCL statements available.
1 COMMIT
2 ROLLBACK
3 SAVEPOINT
1. COMMIT ::
Commit will be used to make the changes made by DML statements permanent to the database. After performing DML operations , if we issue commit then those changes will be made permanent to the database. If Auto commit option for session is enabled, then this is not required as commit takes place automatically.
Note : DDL statements will carry implicit commit. So, if we issue DDL statement against the database, after doing some DML operations , then due to implicit commit of DDL, previous DML statements also will be commited as commit of DDL applies for the session till that point.
COMMIT;
2. ROLLBACK ::
Rollback will be used to discard the changes made by DML statements to the database. If auto commit option enabled in the session , then there is no use with Rollback statements as transactions will be commited automatically.
So, If we give Rollback then any pending changes to the database which are made by DML statements will be discarded.
ROLLBACK;
3. SAVEPOINT ::
To Rollback the changes to a certain transaction point, we will use SAVEPOINT. I will discuss about this in future posts while discussing PL/SQL.
DCL ::
DCL means Data Control Language. These statements are used for controlling the access to database objects for users. Generally these statements will be used by DBA people to control the access of users to the database.
We have 2 DCL statements available in SQL.
1. GRANT
2. REVOKE
1. GRANT ::
Grant will be used for giving permissions on the database to users. Using this we can give any type of permissions to the users on the database.
For ex if we want to give Select permission on all the database tables to a user,
GRANT SELECT ANY TABLE TO user_name;
If we want to give select permission on specific table then
GRANT SELECT ON tab_name TO user_name;
If we want to give Create table permission then,
GRANT CREATE TABLE TO user_name;
Like this we can give any privilege to the users on the database.
2. REVOKE ::
Revoke will be used to remove the permissions which are granted previously to the users on the database.
IF we want to remove permissions given in the above statements, then we can use following statements.
REVOKE SELECT ANY TABLE FROM user_name;
REVOKE SELECT ON tab_name FROM user_name;
REVOKE CREATE TABLE FROM user_name.
Like this using DCL statements we can control the access of users to the database.
Difference Between DELETE and TRUNCATE ::
---> Delete is DML where as Truncate is DDL.
---> Delete requires transaction control as it is DML. Truncate does not require transaction control as it is
DDL
---> If we remove data using DML, then we can get back it by giving Rollback (if commit not done). But
we cannot get the data removed by Truncate (auto commit).
---> Using Delete we can remove specific rows (using where clause) or total rows also. But using Truncate
we can remove entire rows only. (we cannot use where clause with truncate).
---> Truncate is faster than Delete.
Nice post very helpful
ReplyDeletedbakings
Check out more about sql commands here
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteAppreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
ReplyDeleteoracle training in bangalore
Wonderful illustrated information. I thank you about that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject !. oracle training in chennai
ReplyDeleteHard Rock Hotel and Casino Las Vegas - MapYRO
ReplyDeleteRealtime 태백 출장샵 driving directions to Hard 문경 출장샵 Rock Hotel and 동해 출장샵 Casino Las Vegas, based on live traffic updates and 이천 출장샵 road conditions – from MapYRO. 김해 출장마사지
bitlis
ReplyDeleteurfa
mardin
tokat
çorum
Q3GLOS
van
ReplyDeleteerzincan
sivas
ağrı
manisa
4YUQ2A
İstanbul Lojistik
ReplyDeleteZonguldak Lojistik
Konya Lojistik
Ağrı Lojistik
Ordu Lojistik
81TSR
adana evden eve nakliyat
ReplyDeletebolu evden eve nakliyat
diyarbakır evden eve nakliyat
sinop evden eve nakliyat
kilis evden eve nakliyat
NİR
hatay evden eve nakliyat
ReplyDeleteısparta evden eve nakliyat
erzincan evden eve nakliyat
muğla evden eve nakliyat
karaman evden eve nakliyat
5CXNQ1
tekirdağ evden eve nakliyat
ReplyDeletekocaeli evden eve nakliyat
yozgat evden eve nakliyat
osmaniye evden eve nakliyat
amasya evden eve nakliyat
J3ORA
düzce evden eve nakliyat
ReplyDeletedenizli evden eve nakliyat
kırşehir evden eve nakliyat
çorum evden eve nakliyat
afyon evden eve nakliyat
V51O
579ED
ReplyDeleteTekirdağ Parça Eşya Taşıma
Ankara Lojistik
Urfa Evden Eve Nakliyat
Bartın Evden Eve Nakliyat
Rize Lojistik
AAA9F
ReplyDeleteÇerkezköy Marangoz
Siirt Lojistik
Bayburt Parça Eşya Taşıma
Balıkesir Parça Eşya Taşıma
Çerkezköy Korkuluk
Van Parça Eşya Taşıma
Maraş Şehirler Arası Nakliyat
Pursaklar Parke Ustası
Afyon Lojistik
8EF2C
ReplyDeleteZonguldak Lojistik
Ünye Kurtarıcı
Rize Şehirler Arası Nakliyat
Çerkezköy Organizasyon
Kırklareli Parça Eşya Taşıma
Hakkari Şehirler Arası Nakliyat
Isparta Evden Eve Nakliyat
Bayburt Parça Eşya Taşıma
Denizli Şehirler Arası Nakliyat
9DB4C
ReplyDeleteHuobi Güvenilir mi
Mardin Parça Eşya Taşıma
Sincan Boya Ustası
Antep Parça Eşya Taşıma
Balıkesir Evden Eve Nakliyat
Manisa Şehir İçi Nakliyat
Amasya Parça Eşya Taşıma
İstanbul Evden Eve Nakliyat
Antep Şehirler Arası Nakliyat
17C9E
ReplyDeleteÇerkezköy Bulaşık Makinesi Tamircisi
Artvin Evden Eve Nakliyat
Osmaniye Evden Eve Nakliyat
Referans Kimliği Nedir
Ankara Asansör Tamiri
Adıyaman Evden Eve Nakliyat
Batman Evden Eve Nakliyat
Antalya Evden Eve Nakliyat
Ünye Yol Yardım
F5594
ReplyDeleteYozgat Evden Eve Nakliyat
Kripto Para Nedir
Lbank Güvenilir mi
Ünye Oto Lastik
Bitmex Güvenilir mi
Bayburt Evden Eve Nakliyat
Çerkezköy Motor Ustası
Referans Kimliği Nedir
Etlik Boya Ustası
78502
ReplyDeletebinance %20
12A56
ReplyDeleteresimli magnet
referans kimliği nedir
referans kimliği nedir
binance referans kodu
binance referans kodu
9B0D1
ReplyDeleteSoundcloud Beğeni Satın Al
Kwai Takipçi Hilesi
Referans Kimliği Nedir
Chat Gpt Coin Hangi Borsada
Linkedin Takipçi Satın Al
Expanse Coin Hangi Borsada
Periscope Takipçi Hilesi
Coin Kazanma
Bitcoin Madenciliği Siteleri
C0542
ReplyDeleteKwai Beğeni Hilesi
Floki Coin Hangi Borsada
Pepecoin Coin Hangi Borsada
Görüntülü Sohbet
Periscope Takipçi Hilesi
Twitch İzlenme Satın Al
Soundcloud Takipçi Satın Al
Star Atlas Coin Hangi Borsada
Linkedin Beğeni Satın Al
C939D
ReplyDeleteuniswap
shiba
phantom
roninchain
arculus
zkswap
layerzero
poocoin
uwu lend
E47B5
ReplyDeletesohbet canlı
en güvenilir kripto borsası
bitget
bitcoin nasıl oynanır
mercatox
kredi kartı ile kripto para alma
canlı sohbet uygulamaları
bitexen
bkex
Thank You and that i have a dandy offer: What House Renovations Can You Claim On Tax typical renovation costs
ReplyDelete5BC411E843
ReplyDeletegalxe
aethir
medi finance
dymension stake
rocketpool
bitget
rocketpool stake
mitosis
dogwifhat
45B382CD7B
ReplyDeletetakipçi fiyat
1018EFBD9F
ReplyDeleteinstagram ucuz takipçi