Year End Sale: Get Upto 40% OFF on Live Training! Offer Ending in
D
H
M
S
Get Now

SQL Commands

Level : Beginner
Mentor: Shailendra Chauhan
Duration : 00:02:00

Data Definition Language (DDL)

DDL is used for defining and managing the structure of a database, including creating, altering, and deleting database objects such as tables, indexes, and views.

CREATE

Used to create database objects like tables, views, and indexes.

Example

CREATE TABLE employees (
  emp_id INT PRIMARY KEY,
  emp_name VARCHAR(50)
);

DROP

Used to delete database objects like tables or views.

Example

DROP TABLE employees;

ALTER

Used to modify the structure of existing database objects.

Example

ALTER TABLE employees
ADD emp_salary DECIMAL(10, 2);

Data Manipulation Language (DML)

DML is used for manipulating the data stored within a database, including inserting, updating, and deleting records within tables.

INSERT

Used to insert data into a table.

Example

INSERT INTO employees (emp_id, emp_name, emp_salary)
VALUES (1, 'John Doe', 50000);

UPDATE

Used to modify existing data in a table.

Example

UPDATE employees
SET emp_salary = 55000
WHERE emp_id = 1;

DELETE

Used to remove data from a table.

Example

DELETE FROM employees
WHERE emp_id = 1;

Data Control Language (DCL)

DCL is used for managing the permissions and access control to the database objects, including granting and revoking privileges to users and roles. GRANT: Used to give specific privileges to users or roles.

Example

GRANT SELECT ON employees TO user1;

REVOKE

Used to revoke previously granted privileges from users or roles.

Example

REVOKE SELECT ON employees FROM user1;

Transaction Control Language (TCL)

TCL is used for managing transactions within a database, including controlling their initiation, committing changes, and rolling back in case of errors. COMMIT: Used to save changes made during the current transaction.

Example

COMMIT;

ROLLBACK

Used to undo changes made during the current transaction.

Example

ROLLBACK;

SAVEPOINT

Used to set a point within a transaction to which you can later roll back.

Example

SAVEPOINT my_savepoint;

Data Query Language (DQL)

DQL is used for querying and retrieving data from the database using SQL SELECT statements.

SELECT

Used to retrieve data from one or more tables.

Example

SELECT emp_name, emp_salary
FROM employees
WHERE emp_salary > 50000;
Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this