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.
[Link]
[Link]
DDL [Link]
[Link]
[Link]
[Link]
DML [Link]
[Link]
[Link]
SQL DCL [Link]
DQL [Link]
[Link]
TCL [Link] Back
[Link] point
[Link]
CREATE TABL
E Employees (
ID Number,
Name VARCHAR(50),
Age Number);
#Quote #Programming #Selfcare
[Link]
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
[Link]
DELETE FROM Employee
WHERE ID = 1;
#Quote #Programming #Selfcare
Output:-
ID NAME AGE
2 Ankush 23
3 Ankit 23
[Link]
UPDATE Employee SET
Age = 30 WHERE ID =
2;
#Quote #Programming #Selfcare
Output:- ID NAME AGE
2 Ankush 30
3 Ankit 23
[Link]
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".
[Link]
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.
[Link]
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.
[Link]
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.
[Link]
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.
[Link]
SAVEPOINT sp1;
#Quote #Programming #Selfcare
[Link]
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
[Link]
ROLLBACK TO
SAVEPOINT sp1;
#Quote #Programming #Selfcare
[Link]
TRUNCATE TABLE
table_name;
#Quote #Programming #Selfcare
Output:-
ID Number
Name Varchar(10)
Age Number
DROP TABLE Emp;
SEARCH:-
[Link]
S
elect * from Emp*
#Quote #Programming #Selfcare
“Table or view doesn’t exist”