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

LearnCoding SQL

Uploaded by

Shlok Chaudhari
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)
3 views

LearnCoding SQL

Uploaded by

Shlok Chaudhari
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/ 11

Learn Coding

INTRODUCTION TO

SQL
LEA
RN CODING

Ankush Kushwaha Akhilesh Kushwaha

visit our Youtube channel for more content


What is SQL?
SQL stands for Structured Query
Language and It is used to communicate
with the database.

SQL provides a standard way to create


objects,
insert, update, delete and select records
from the databases.

SQL supported almost all relational


database management systems, such as
MySQL, Oracle, Microsoft SQL Server,
PostgreSQL, and SQLite.
1.Create
2.Alter
DDL 3.Drop
4.Rename
5.Truncate

1.Insert
DML 2.Update
3.Delete

1.Grant
SQL DCL 2.Revoke

DQL 1.Select

1.Commit
TCL 2.Roll Back
3.Save point
Motivation.txt

CREATE TABL
E Employees (
ID Number,
Name VARCHAR(50),
Age Number);

#Quote #Programming #Selfcare

Motivation.txt

INSERT INTO Employees VALUES


(1, 'Akhilesh, 22);

INSERT INTO Employees VALUES


(2, 'Ankush', 23);

INSERT INTO Employees VALUES


(3, 'Ankit', 23);

Select * From Employee

#Quote #Programming #Selfcare

Employee
ID NAME AGE

1 Akhilesh 22

2 Ankush 23

3 Ankit 23
Motivation.txt

DELETE FROM Employee


WHERE ID = 1;

#Quote #Programming #Selfcare

Output:-
ID NAME AGE

2 Ankush 23

3 Ankit 23

Motivation.txt

UPDATE Employee SET


Age = 30 WHERE ID =
2;

#Quote #Programming #Selfcare

Output:- ID NAME AGE

2 Ankush 30

3 Ankit 23
Motivation.txt

ALTER TABLE Employee


RENAME TOEmp;

#Quote #Programming #Selfcare

Emp
ID Number

Name Varchar(10)

Age Number

GRANT statement:
Suppose you have a table named "Emp" and
you want to grant SELECT and INSERT
permissions to a user named "user1".

Motivation.txt

GRANT SELECT, INSERT ON


Employees TO user1;

#Quote #Programming #Selfcare


REVOKE statement:
Now, let's revoke the SELECT and
INSERT permissions from "user1" on
the "Emp" table.

Motivation.txt

REVOKE SELECT, INSERT ON


Employees FROM user1;

#Quote #Programming #Selfcare

COMMIT statement:
Suppose you have performed a series of
data modifications (INSERT, UPDATE,
DELETE) and want to commit those
changes permanently to the database.

Motivation.txt

Commit;

#Quote #Programming #Selfcare


ROLLBACK statement:
Suppose you have performed a series of
data modifications but want to undo
those changes and revert to the
previous state of the data.

Motivation.txt

Rollback;

#Quote #Programming #Selfcare

SAVEPOINT statement:
Suppose you want to set a savepoint
within a transaction, allowing you to
rollback to that specific point if needed.

Motivation.txt

SAVEPOINT sp1;

#Quote #Programming #Selfcare


Motivation.txt

INSERT INTO Employe


es (ID, Name,
Age)
VALUES (1, 'John', 25);
UPDATE Employees SET Age = 22 WHERE
ID = 1;
DELETE FROM Employees WHERE ID = 2:

#Quote #Programming #Selfcare

Motivation.txt

ROLLBACK TO
SAVEPOINT sp1;

#Quote #Programming #Selfcare

Motivation.txt

TRUNCATE TABLE
table_name;

#Quote #Programming #Selfcare


Output:-
ID Number

Name Varchar(10)

Age Number

DROP TABLE Emp;

SEARCH:-
Motivation.txt

S
elect * from Emp*

#Quote #Programming #Selfcare

“Table or view doesn’t exist”

You might also like