0% found this document useful (0 votes)
29 views21 pages

Short Notes: @maheshpal Singh Rathore @mpsrathore2020

SQL is a programming language used to manage and query relational databases. It allows users to define tables with relationships and then perform operations like inserting, updating, deleting, and selecting data. SQL commands are classified into four main categories - DDL for data definition, DML for data manipulation, DCL for data control, and TCL for transaction control. Common commands include CREATE, SELECT, INSERT, UPDATE, DELETE, COMMIT, and ROLLBACK.

Uploaded by

Goitom Mulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views21 pages

Short Notes: @maheshpal Singh Rathore @mpsrathore2020

SQL is a programming language used to manage and query relational databases. It allows users to define tables with relationships and then perform operations like inserting, updating, deleting, and selecting data. SQL commands are classified into four main categories - DDL for data definition, DML for data manipulation, DCL for data control, and TCL for transaction control. Common commands include CREATE, SELECT, INSERT, UPDATE, DELETE, COMMIT, and ROLLBACK.

Uploaded by

Goitom Mulu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

SQL

Short Notes

@Maheshpal Singh Rathore


@mpsrathore2020
What is SQL ?
SQL (Structured Query Language) is a
programming language used to manage
and manipulate relational databases .

It allows users to create, modify, and


query databases that are organized in a
structured way, where data is stored in
tables with defined relationships
between them.

@Maheshpal Singh Rathore


@mpsrathore2020
SQL is widely used in various industries
such as banking, healthcare, and e-
commerce, to manage large amounts of
data efficiently and effectively.

SQL can perform a wide range of


operations including selecting, inserting,
updating, and deleting data from a
database.

@Maheshpal Singh Rathore


@mpsrathore2020
It is considered a standard language
for interacting with relational
databases and is supported by most
database management systems.

@Maheshpal Singh Rathore


@mpsrathore2020
Types of SQL Commands
SQL (Structured Query Language)
commands can be broadly classified into
four categories:

DDL
DML
DCL
TCL
@Maheshpal Singh Rathore
@mpsrathore2020
DDL Command
DDL (Data Definition Language): These
commands are used to define the
structure and layout of the database.
Some common DDL commands includes:

CREATE
ALTER
DROP
TRUNCATE

@Maheshpal Singh Rathore


@mpsrathore2020
Examples :
CREATE
This command is used to create a new
table in the database. Here's an
example:

@Maheshpal Singh Rathore


@mpsrathore2020
ALTER
This command is used to modify the
structure of an existing table. Here's an
example:

@Maheshpal Singh Rathore


@mpsrathore2020

DROP
This command is used to delete an
existing table and all its data. Here's an
example:

TRUNCATE
This command is used to delete all the
data from an existing table. Here's an
example:

@Maheshpal Singh Rathore


@mpsrathore2020
DML Command
DML (Data Manipulation Language):
These commands are used to manipulate
the data in the database.
Some common DML commands includes :

SELECT
INSERT
UPDATE
DELETE
@Maheshpal Singh Rathore
@mpsrathore2020
SELECT
This command is used to retrieve data from one
or more tables in the database.
For Example :

If you want to retrieve specific columns from the table,


we can list them after the SELECT

@Maheshpal Singh Rathore


@mpsrathore2020
INSERT
This command is used to insert new data into a
table. Here's an example:

UPDATE
This command is used to update existing data in
a table. Here's an example:

@Maheshpal Singh Rathore


@mpsrathore2020
DELETE
This command is used to delete data
from a table. Here's an example:

@Maheshpal Singh Rathore


@mpsrathore2020
DCL Command
DCL (Data Control Language): These
commands are used to control access to
the database.

Some common DCL commands


include :

GRANT
REVOKE

@Maheshpal Singh Rathore


@mpsrathore2020
GRANT
This command is used to grant permissions
to users or roles to perform certain actions
on database objects. Here's an example:

This command grants the "analyst" user


or role the permission to select, insert,
and update data in the "students" table.

@Maheshpal Singh Rathore


@mpsrathore2020
REVOKE
This command is used to revoke permissions
from users or roles to perform certain
actions on database objects. Here's an
example:

This command revokes the "guest" user or


role's permission to select data from the
"students" table.

@Maheshpal Singh Rathore


@mpsrathore2020
TCL Command
TCL (Transaction Control Language):
These commands are used to manage
transactions in the database.

Some common TCL commands


includes:

COMMIT
ROLLBACK

@Maheshpal Singh Rathore


@mpsrathore2020
COMMIT
This command is used to save all changes
made during a transaction.
Suppose you have a database table named
"employees" that contains information about
employees in your company. You want to update
the salary of an employee with the employee ID
of 12345. You can use the following SQL
statements to do this:

@Maheshpal Singh Rathore


@mpsrathore2020
ROLLBACK
This command is used to undo all changes made
during a transaction and restore the database
to its previous state.

Suppose you have a database table named


"orders" that contains information about
customer orders. You want to update the
quantity of an order with the order ID of 123. You
can use the following SQL statements to do this:

@Maheshpal Singh Rathore


@mpsrathore2020
After executing these statements, you
realize that you made a mistake and the
quantity should have been set to 10 instead
of 5. You can use the ROLLBACK command
to undo the changes made in the
transaction:

The ROLLBACK statement undoes all the


changes made in the current transaction
and restores the database to its state
before the transaction started.

@Maheshpal Singh Rathore


@mpsrathore2020
Did you find this
post helpful ?
Follow us on
@Maheshpal Singh Rathore
@mpsrathore2020

@Kiran Kanwar Rathore


@kiranrathore123

Like , Save, and Share


with
your friends !!!

Credit - Internet

You might also like