Monday, April 29, 2019

SQL Commands | DDL, DML, TCL, DCL, DQL

SQL Commands:

SQL Command
 
SQL commands are guidelines, coded into SQL proclamations, which are utilized to speak with the database to perform explicit undertakings, work, capacities and inquiries with information.
SQL commands can be utilized for looking through the database as well as to perform different capacities like, for instance, you can make tables, add information to tables, or alter information, drop the table, set consents for clients. SQL directions are assembled into four noteworthy classifications relying upon their usefulness:

Information Definition Language (DDL) -


These SQL commands are used for making, altering, and dropping the structure of database objects. The commands are CREATE, ALTER, DROP, RENAME, and TRUNCATE.

See More >>>

Information Manipulation Language (DML) -


These SQL commands are used for putting away, recovering, changing, and erasing information.
These Data Manipulation Language commands are: INSERT, UPDATE, and DELETE.

See More >>>

Exchange Control Language (TCL) -


These SQL commands are used for overseeing changes influencing the information. These commands are COMMIT, ROLLBACK, and SAVEPOINT.

See More >>>

Information Control Language (DCL) -


These SQL commands are used for giving security to database objects. These commands are GRANT and REVOKE.

See More >>>

Data Query Language (DQL) -


This SQL command is used for retrieve value from database. This command is SELECT.

See More >>>
Recommended :

Data Definition Language :
Create
Drop
Alter
Truncate
Data Manipulation Language :
Insert
Update
Delete
Data Control Language :
Grant
Revoke
Transaction Control Language :
Commit
Rollback
Savepoint
Data Query Language:
Select



Tuesday, April 16, 2019

ROLLBACK | Rollback In SQL Server

ROLLBACK Command



This command restore the database to last committed state.

It is also used with savepoint command to jump to a savepoint in a transaction.

Syntax :

1) ROLLBACK;

2) ROLLBACK savepoint_name;

Example :

ROLLBACK save1;

Note :

We can rollback the same data that was not previously committed.

* * * * * * * * * * * * * *

In Easy Lanhguage

Rollback command used to rollback(undo) all database or particular savepoint.


SAVEPOINT | Savepoint In SQL

SAVEPOINT Command



Savepoint command used to save temporarily transaction, so that you can rollback to that point whenevee necessary.
Savepoint command used to create savepoint after change the database.

Syntax :

SAVEPOINT savepoint_name;

Example :

SAVEPOINT save1;


Note :

If we have made a mistake in the database and use rollback without the savepoint , then it rollbacks the complete transaction and we lost all data.



Commit | Commit In SQL Server | TCL Command

Commit Command

Commit command used to save permanently transaction to database.

Syntax :

commit;

Example :

commit;



Monday, April 15, 2019

TCL | TCL Commands | SQL Command

Transaction Control Language

In SQL, there are following types of TCL Commands. As under,
  • COMMIT
  • ROLLBACK
  • SAVE POINT
TCL commands are used to manage transaction in database. Like commit, rollback, save point.

These TCL commands are used to manage the changes made by DML commands.



COMMIT Command

Commit command used to save transaction into the database permanently.

Syntax :

commit ;

Example :

commit ;

ROLLBACK Command

Rollback command used to restores the database to last committed state.
It can be also used with SAVEPOINT command to jump to a save point in an ongoing database transaction.
Syntax :

ROLLBACK TO savepoint_name ;

Rollback command has one parameter

1) savepoint_name - This parameter used to provide name of  save point, which we want to rollback.

Example :

DELETE FROM Customer01 WHERE C_Id = 105;
ROLLBACK;

SAVEPOINT Command

Savepoint command used to set a point in a transaction. When you can roll the transaction back to a certain point without rolling back the entire transaction.

Syntax :

SAVEPOINT savepoint_name;

Example :

SAVEPOINT cust_1;


Recommanded :

Commit Command
Rollback Command
Savepoint Command

Note:

  • If we are use DML commands (INSERT, UPDATE, DELETE), the changes made by these commands are not permanent, until the current session is closed.