DEV Community

Cover image for SQL- Commands intro
Madhu babu Duggirala
Madhu babu Duggirala

Posted on • Edited on

SQL- Commands intro

Structure Query Language(SQL)
  • SQL is a collection of statements used to communicate with Data Bases. SQL can also be called as Sequel.

  • To communicate with data bases human needs a language that is SQL. In the same way SQL also needs some set of commands to communicate with database.

  • When you are going to start SQL. You need keep know basic elements of database.

Database contains 'n' number of schemas, Schemas contains 'n' number of tables, Tables contains 'n' number of rows and columns.

DataBase_visualisation

In SQL there are five commands in total:

  1. DQL(Data Query Language).
  2. DDL(Data Definition Language).
  3. DML(Data Manipulation Language).
  4. DCL(Data Control Language).
  5. TCL(Transaction Control Language).

Further I will also share some shortcuts to remember commands in sql

SQL Commands chart

Data Query Language(DQL):
  • The name itself specifies that this is a query language.(Query is a statement to retrieve something from the database with some conditions included in it).
  • DQL has only one command i.e. SELECT.
Syntax:
SELECT column1,column2,column3.....
Enter fullscreen mode Exit fullscreen mode
Data Definition Language(DDL):
  • DDL commands are used to define the structure of the schemas i.e, it defines the structure of tables etc..
Syntax:
```<DDL_Command> Table <table_name>```
Enter fullscreen mode Exit fullscreen mode
  • It contains 5 commands:
    1. DROP
    2. RENAME
    3. CREATE
    4. ALTER
    5. TRUNCATE

To remember commands easily follow the first letter of each command which is DR.CAT

Data Manipulation Language(DML):
  • DML commands are used to manipulate the data present in the data base.
Syntax:

<DML_Command> <table_name>

  • It contains 5 commands:
    1. LOCK
    2. UPDATE
    3. CALL
    4. INSERT
    5. DDELETE

To remember commands easily follow the first letter of each command which is LUCID

Data Control Language(DCL):
  • DCL commands delay with permissions and rights in the database.

  • It contains 5 commands:

    1. GRANT
    2. REVOKE
Transaction Control Language(TCL):
  • Transaction: Transaction is a set of SQL statements.

    Transactions are categorised into 3 types:

    • Explicit
    • Implicit
    • Auto commit
  • To control the flow of sql statements commands of TCL is used.

  • TCL contains 3 commands:

    1. Commit
    2. Rollback
    3. Savepoint
Checkout my design: SQL Commands

In this Blog, I covered some prerequisites, essential SQL commands and share tips to easily remember. Whether you're a beginner or an experienced developer, there's something valuable for everyone.

Don't miss out on this opportunity to level up your SQL. Check out the blog and let me know what you think.

Your appreciation and follows really motivate me to create more content like this. If you feel that you’ve learned something, please hit the follow button and let me know what you think. 😊

👉 follow me on Linkedin

Happy coding!

Top comments (1)

Collapse
 
madhuraj9030 profile image
Madhu babu Duggirala

Feel free to share your thoughts here in comments, so that it would be helpful for me to learn something and change accordingly.. 😊