SQL Commands

Based on their nature, SQL commands can be divided into four main groups.

Data Definition Language (DDL):

This group includes those commands that are used to create, define, modify or delete a table or object in a database. Like Create, Alter, Drop, etc.

Data Manipulation Language (DML):

This group includes those commands that are required to retrieve, create, modify or delete a record in a table from a database. Like Select, Insert, Update, Delete, etc.

Data Control Language (DCL):

This group includes those commands that are used to give to or take back the permission from a user. It controls the database access and defines user controls and permissions. Like Grant, Revoke, etc.

Transactional Control Language (TCL):

This group is used to manage different transactions occurring within a database, you can do it with COMMIT, ROLLBACK statements.

SQL Elements:

For the ease of understanding, SQL has been divided into language elements. Some of them are:

  1. Clauses: Elements that are the essential part of statements.
  2. Queries: Elements that are used to retrieve the data from database that matches certain conditions.
  3. Predicates: Conditions specifying elements that can be manipulated to SQL.
  4. Expressions: Elements that are employed to give scalar results or tables.
  5. Statements: Elements that produce determined effect on schemas and data.

SQL Functions:

SQL functions are used to do certain mathematical operations with your data. Most common SQL functions are listed below:

  1. count(): used to count the number of records
  2. sum(): used to add the values in records
  3. avg(): used to average values in records
  4. max(): used to find the highest value among all the records
  5. min(): used to find the lowest value in all the records

SQL Comments:

The SQL comments are used between the SQL commands to explain SQL statements. A comment starts with a “--“ sign that will not be executed by the SQL server or interpreter. If your comment consists of multiple lines, then write it in between “/* (comment) */”.

Example 1:

--To delete a table use the below-mentioned statement

--To delete a table use the below-mentioned statement
DROP TABLE “table name”;

Example 2:

/* To delete an entire table
or all the rows in a table
the drop table statement is used */
DROP TABLE “table name”;

Text in SQL:

To replace or modify a value you need to provide the new value. Remember for writing any text for searching or for replacing, type the text in inverted commas like this ‘Mexico‘.

Basics of Standard SQL Commands:

All SQL statements are ended with a ";" sign. SQL keywords are not case sensitive. The integrity of a database remains secured and protected with SQL.

This tutorial will have complete instructions on the basics of each SQL command. Once you review this material, you will be able to run your commands, practice them, create your exclusive tables and along with it, you can also perform inserts, selects, deletes, updates, and drops.

SQL when executed with the best practices, can play a crucial part in a database building, database application planning, and in the performance of a database system.