0% found this document useful (0 votes)
2 views

SQL-Commands-A-Comprehensive-Overview

This document provides an overview of core SQL commands, including Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Transaction Control Language (TCL), and Data Query Language (DQL). It includes syntax and examples for creating, altering, and deleting database objects, as well as managing data and permissions. Additionally, it covers transaction management and data retrieval techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL-Commands-A-Comprehensive-Overview

This document provides an overview of core SQL commands, including Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Transaction Control Language (TCL), and Data Query Language (DQL). It includes syntax and examples for creating, altering, and deleting database objects, as well as managing data and permissions. Additionally, it covers transaction management and data retrieval techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

SQL Commands: A

Comprehensive Overview
This presentation provides a comprehensive overview of the core
SQL commands, covering Data Definition Language (DDL), Data
Manipulation Language (DML), Data Control Language (DCL),
Transaction Control Language (TCL), and Data Query Language
(DQL).
uc
by umesh chauhan
Data Definition Language (DDL): Defining
Your Database
CREATE ALTER DROP TRUNCATE

Creates new database Modifies existing Deletes database objects Removes all data from a
objects, including tables, database objects, such permanently from the table, but keeps the
views, indexes, and as adding or removing database, including table structure intact.
stored procedures. columns from a table. tables, views, indexes,
and stored procedures.
DDL Syntax and Examples
CREATE TABLE ALTER TABLE
CREATE TABLE customers ALTER TABLE customers
(customer_id INT PRIMARY ADD COLUMN phone
KEY, customer_name VARCHAR(20);
VARCHAR(255), email
VARCHAR(255));

DROP TABLE TRUNCATE TABLE


DROP TABLE customers; TRUNCATE TABLE customers;
Data Manipulation Language (DML):
Managing Data
INSERT UPDATE DELETE

Adds new rows to a table. Modifies existing rows in a table. Removes existing rows from a table.
DML Syntax and Examples
INSERT UPDATE
INSERT INTO customers UPDATE customers SET
(customer_name, email) email =
VALUES ('John Doe', '[email protected]'
'[email protected]'); WHERE customer_id = 1;

DELETE
DELETE FROM customers WHERE customer_id = 2;
Data Control Language (DCL): Managing
Permissions
GRANT REVOKE

Grants access privileges to database users. Revokes access privileges from database users.
Transaction Control
Language (TCL):
Managing Transactions
1 COMMIT 2 ROLLBACK
Saves all changes made Reverts all changes made
in a transaction in a transaction to their
permanently. original state.

3 SAVEPOINT
Creates a checkpoint within a transaction, allowing you to
rollback to that point if needed.
Data Query Language (DQL): Retrieving
Information
SELECT FROM WHERE GROUP BY

Specifies the columns to Specifies the table to Filters the data based on Groups rows with similar
retrieve from a table. retrieve data from. specific conditions. values in a column.
DQL Syntax and Examples
SELECT * FROM customers; SELECT customer_name, email FROM customers
WHERE customer_id = 1;
Retrieves all columns and rows from the customers table.
Retrieves customer name and email from the customers table
for customer with ID 1.

SELECT COUNT(*) FROM customers; SELECT customer_name, COUNT(*) AS order_count


FROM orders GROUP BY customer_name ORDER BY
Counts the number of rows in the customers table.
order_count DESC;
Counts the number of orders placed by each customer and
sorts the results in descending order by order count.

You might also like