Back to: Database (DX) Design Course
Here are some basic SQL queries and commands:
- SELECT: retrieves data from a database table.
Example: SELECT * FROM customers;
This query retrieves all data from the “customers” table.
- INSERT: inserts new data into a database table.
Example: INSERT INTO customers (name, email) VALUES (‘John Doe’, ‘[email protected]‘);
This query inserts a new record into the “customers” table with the name “John Doe” and email “[email protected]“.
- UPDATE: modifies existing data in a database table.
Example: UPDATE customers SET email = ‘[email protected]‘ WHERE name = ‘John Doe’;
This query updates the email address of the customer with the name “John Doe” to “[email protected]“.
- DELETE: deletes data from a database table.
Example: DELETE FROM customers WHERE name = ‘John Doe’;
This query deletes the record of the customer with the name “John Doe” from the “customers” table.
- CREATE: creates a new database table.
Example: CREATE TABLE orders (id INT, customer_id INT, order_date DATE, total_amount DECIMAL(10,2));
This query creates a new table called “orders” with columns for id, customer_id, order_date, and total_amount.
- ALTER: modifies the structure of a database table.
Example: ALTER TABLE orders ADD COLUMN order_status VARCHAR(20);
This query adds a new column called “order_status” to the “orders” table.
- DROP: deletes a database table.
Example: DROP TABLE orders;
This query deletes the “orders” table from the database.
Let’s take it Further…
Types Of SQL Commands :
- SQL Categorizes its commands on the basis of functionalities performed by them. There are five types of SQL Commands which can be classified as:
- DDL(Data Definition Language).
- DML(Data Manipulation Language).
- DQL(Data Query Language).
- DCL(Data Control Language).
- TCL(Transaction Control Language).
Types Of SQL Commands :
Data Definition Language(DDL)
- In order to make/perform changes on the physical structure of any table residing inside a database, DDL is used. These commands when executed are auto commit in nature and all the changes in the table are reflected and saved immediately. DDL commands includes :Â Â

Data Manipulation Language(DML)
- Once the tables are created and database is generated using DDL commands, manipulation inside those tables and databases is done using DML commands. The advantage of using DML commands is, if in case any wrong changes or values are made, they can be changes and rolled back easily. DML commands includes :

Data Control Language(DCL)
- DCL commands as the name suggests manages the matters and issues related to the data control in any database. TCL commands mainly provides special privilege access to users and is also used to specify the roles of users accordingly. There are two commonly used DCL commands, these are:

Data Query Language(DQL)
- Data query language consists of only one command over which data selection in SQL relies. SELECT command in combination with other SQL clauses is used to retrieve and fetch data from database/tables on the basis of certain conditions applied by user.

Types Of SQL Commands : Transaction Control Language(TCL)
- Transaction Control Language as the name suggests manages the issues and matters related to the transactions in any database. They are used to rollback or commit the changes in the database.
- Roll back means “Undo” the changes and Commit means “Applying” the changes. There are three major TCL commands.
