Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
195 views

SQL Short Notes PDF

This document provides an overview of SQL (Structured Query Language) and its main commands. SQL is used for managing data in relational database management systems and has commands for data definition (DDL), data manipulation (DML), and data control (DCL). The DDL commands CREATE, ALTER, DROP, and TRUNCATE are used to define and modify database structures. The DML commands INSERT, UPDATE, and DELETE are used to manipulate the data. The DCL commands GRANT, REVOKE, COMMIT, and ROLLBACK are used to control access privileges and transactional changes to the data.

Uploaded by

Care Cure
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
195 views

SQL Short Notes PDF

This document provides an overview of SQL (Structured Query Language) and its main commands. SQL is used for managing data in relational database management systems and has commands for data definition (DDL), data manipulation (DML), and data control (DCL). The DDL commands CREATE, ALTER, DROP, and TRUNCATE are used to define and modify database structures. The DML commands INSERT, UPDATE, and DELETE are used to manipulate the data. The DCL commands GRANT, REVOKE, COMMIT, and ROLLBACK are used to control access privileges and transactional changes to the data.

Uploaded by

Care Cure
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

SQL

Short Notes !

DATABASE

By @Curious_.programmer

(!Jecurious_.progt'IIIMIIII'
What is SQL?
• sql is stand for structured query language.

• This database language is mainly designed


for maintaining the data in relational
database management systems.

• sql is standard language for accessing and


manipulating database.

Types of SQL Commands:

DML DCL
Data Manipulation Data Control
language language

CREATE INSERT GRANT COMMIT

ALTER REVOKE ROLLBACK


UPDATE
SAVEPOINT
DROP DELETE

TRUNCATE

{!Jueurtous_.progt'M111181'
DDL COMMANDS:
• DDL (Data Definition Language) used to change the structure of the
table Like creating the table, altering the table&. Deleting the table.

• All the commands in the DDL are auto Committed that means it
permanently saves all the changes in the database.

1. CREATE:
this command is used to create a new database or table.

Syntax:
CREATE TABLE table_name (
columnl datatype,
column2 datatype,
column3 datatype,

);

Example:
CREATE TABLE Employee
(
EmployeelD int,
FirstName varchar(255) ,
LastName varchar(255),
Addressline varchar(255),
City varchar(255)
);
2. Alter
The ALTER TABLE statement in Structured Query Language allows
you to add, modify, and delete columns of an existing table.

Syntax:
ALTER TABLE table name
ADD column_name datatype;

Example:
AlTER TABLE Employee
ADD Email varchar(255) ;

3. Drop
The DROP TABLE statement is used to drop an existing table in a database.
this command deletes both the structure &. Records Stored in table.

Syntax:
DROP TABLE table_name;

Example:
Drop TABLE Employee

eurious_.programmer
4. TRUNCATE
A truncate SQL statement is used to remove all rows (complete data)
from a table. It is similar to the DELETE statement with no WHERE clause.

Syntax:
TRUNCATE TABLE table_name;

Example:
TRUNCATE TABLE Employee;

DML COMMANDS:
1. INSERT
SQL INSERT statement is a SQL query. It is used to insert a single or a
multiple records in a table.

Syntax:
INSERT INTO table name
VALUES ( value1, value2, value3 ....);

Example:
INSERT INTO STUDENTS (ROLL_NO, NAME, AGE, CITY)
VALUES (1, Yadnyesh, 19, PUNE) ;

eurious_.programmer
2. UPDATE
The UPDATE statement is used to modify the existing records in a table.

syntax:
UPDATE table name
SET columnl = valuel, column2 = value2, ...
WHERE condition;

Example:
UPDATE Customers
SET ContactName = 'Vadu', City= 'pune'
WHERE CustomerlD = 101;

3. DELETE

The DELETE statement is used to delete existing records in a table.

Syntax:
DELETE FROM table_name [WHERE condition];

Example:
DELETE FROM Customers WHERE CustomerName='Vadu";

{!Jgeurious_.progt111M181'
DCL COMMANDS:

1. GRANT
It is used to give user access privileges to a database.

syntax:
GRANT SELECT, UPDATE ON MY_ TABLE TO SOME_USER,
ANOTHER_USER;

2. REVOKE

GRANT SELECT, UPDATE ON MY_ TABLE TO SOME_ USER,


ANOTHER_ USER;

syntax:
REVOKE SELECT, UPDATE ON MY_ TABLE FROM USERl, USER2;
TCL COMMANDS:
1. COMMIT
Commits a Transaction. The COMMIT command saves all the
transactions to the database since the last COMMIT or ROLLBACK
command.

Syntax:
COMMIT;

Example:
DELETE FROM Student WHERE AGE = 20;
COMMIT;

2. ROLLBACK

If any error occurs with any of the SQL grouped statements, all
changes need to be aborted. The process of reversing changes is
called rollback

Syntax:
ROLLBACK;

Example:
DELETE FROM Student WHERE AGE = 20;
ROLLBACK;

{1Jgeurious_.progt'IIIMl8f
PDF uploaded on
Telegram
(Link in bio)

Do join for coding resources, Handwritten ~otes & Quizzes! !

https://t.me/Cunous_Coder

(!Jecurtous_.progt1111111111f

You might also like