SQL

MS SQL Basic
which stands for Structured Query Language, is a language used to add, update, and remove data from databases as well as modify the metadata related to those databases.

SQL Commands or Types of languages in SQL

In order to perform specific data-related tasks, SQL commands are queries sent to the database. Apart from database searches, SQL commands can be used for many other purposes, including making new tables, deleting old ones, updating data in them, and assigning rights to users. SQL commands fall into four main categories based on the functionality they offer:

  • Data Definition Language (DDL) – Database object structures can be created, modified, and removed using these SQL commands. The available commands are as follows: Create, Modify, Delete, and Rename.
  • Data Manipulation Language (DML) – Data can be stored, retrieved, edited, and deleted using these SQL statements. These commands are UPDATE, DELETE, INSERT, and SELECT.
    Data Control Language (DCL) – Database objects are secured using these SQL statements. The GRANT and REVOKE commands are as follows.
  • Transaction Control Language (TCL) – The purpose of these SQL procedures is to handle data modification. The commands COMMIT, ROLLBACK, and SAVEPOINT are as follows
    .
  • Data retrieval Language (DRL) – Select
TRUNCATE DELETE
TRUNCATE is a DDL command. DELETE is a DML Command.
 

TRUNCATE TABLE always locks the table and page but not each row.

DELETE statement is executed using a row lock, each row in the table is locked for deletion.
Cannot use Where Condition. We can specify filters in where clause.
It Removes all the data. It    deletes    specified    data    if       where condition exists.
TRUNCATE    TABLE    cannot    activate    a           trigger because the operation does not log individual row deletions. Delete activates a trigger because the operation is logged individually.
Faster in performance wise, because it doesn’t

keep any logs.

Slower than truncate because, it keeps.

logs.

Rollback is not possible. Rollback is possible.

 

Leave a Reply

Your email address will not be published. Required fields are marked *