Saturday, November 7, 2026
Wednesday, November 4, 2026
SQL Commands
SQL Commands – Definition, Syntax and Examples
SQL (Structured Query Language) is a standard
programming language used to create, manage, manipulate, and retrieve data from
relational databases.
SQL
commands are divided into five main categories:
1. DDL – Data Definition
Language
2. DML – Data Manipulation
Language
3. DQL – Data Query Language
4. DCL – Data Control
Language
5. TCL – Transaction Control
Language
1.
DDL – Data Definition Language
DDL
commands are used to create, modify, and delete database structures such as
tables and databases.
1.
CREATE
Definition: CREATE command is used to create a new
database or table.
Syntax:
CREATE TABLE table_name
(
column1 datatype,
column2 datatype
);
Example:
CREATE TABLE Student
(
RollNo INT,
Name VARCHAR(50),
Age INT,
City VARCHAR(30)
);
2.
ALTER
Definition: ALTER command is used to modify the
structure of an existing table.
Syntax:
ALTER TABLE
table_name
ADD column_name datatype;
Example:
ALTER TABLE
Student
ADD Marks INT;
3.
DROP
Definition: DROP command is used to permanently delete
a table or database.
Syntax:
DROP TABLE
table_name;
Example:
DROP TABLE
Student;
4.
TRUNCATE
Definition: TRUNCATE command is used to delete all
records from a table without deleting its structure.
Syntax:
TRUNCATE TABLE
table_name;
Example:
TRUNCATE TABLE
Student;