0 ratings0% found this document useful (0 votes) 2K views5 pagesSQL Commands Handwritten Notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
i
oe
Gane wake’
SQL COMMANDS
Qhe-progrormmigy- qu
SQL Commands
®SQL commands ave insivuctions . Tt is used to Commu
Wicate with the datobsse. TA is also used to pesform
Specific tasks funclions ond queries oF data
®SL can perform various tasks like creale a table.
Add data to tables , drop the table modify the table
Set Petmission for users
‘Types of SQL Commands :-
There axe five Ly pes of S@L Commands :-
SQL° Command — @theprepramming-gin!
I T
DD. dM .OcL «te Dal
Leseate — Tnsest [Cert Commit L Select
L Drop | Update. Revolce Roll back
| Alley I Delete Save Point
| Runcete
4-Data Definakion Language CDDL)
® DDL changes the structure of the Lable like creatin
a table deleting a table , citering atable ,ete
« All the commands of DDL ave auto-commiltedthat means it
' the database
Pexmanently Save all the changes
Here cre some commands that come andes DDL*
* CREATE
“ALTER
*DRop ° TRUNCATE
O- CRETE:
Tt is used to cseote a new table in dhe dakabes4
Syntax 1 -
CREATE TABLE_-NIAmE CCoLUmMAL_NAME DATATYPE)
Example: =
CREATE TABLE EMPLOYEE CName VARCHARZO), Emoil ¥|
b. DRop :-
Tk is used to delete both the stuctuse and
Necord Stored in the table
Syn Ox i=
DRopP TABLE table name ;
Example :- (Dthe-programming -grl
DRop TABLE EMPLONEE ;
CG. ALTER :- TA is used to alter the shucture of thel
ddlabase. This could be eithes to modita dhe chara
clesistics of an existing attribute os pa obably to
ocd G new alhibute.
i - _
Example
ALTER TABLE STU-DETATLS ADD CADDRESS “VARCHAR 2 G24)
R_TABLE_STU-DETATLS_MODTEY CNAME VARCHAR 2 (29)
®ad. TRUNCATE -
TA iS used to clelele eill the rows from the fable
and free the Space Containing the table.
Syntax:
TRUNCATE TABLE table-heame
Example:~ :
TRUNCATE TABLE EmpLoYer; @the-proyromning gis!
2. ORTH Manipulation Language :-
DML commands are Used to modify the clatabasd
Ti_is Besponsible for all form of changes in the
database. The command of BML is not auo-commited
e TNSERT e UPDATE eDELETE
QO- INSERT --
The INSERT statement is SQL Query. Tt is used
to insest clata into the tow of a table.
Syntax '-
TNSEAT INTO TABLE-NAME
VALUES Cvolue | Value 2 , values value nid:
b. UPDATE 1—
This Command is usec to update or Modify
the value of a column in dhe table,
Syntax: —
UPDATE Lable-name SET [columnname | = value}
v-tolu)
C. DeleTe:- Tk is usecl to gerove one oy mar
row form ctable
+
(a)| Examp| e:-
—t :
DELETE FROM javatjoeint O4the-progrumniy4-gi!
WHERE Author= “Sonoo”’
S. Data Control Language
DCL commands ave used 4o grant and tevoke auth}
ovity Srom ang dotabose User.
0 Grant e Revoke
a+ Grank +7
Th is used to give user acess privileges Ao dalobasd
Example !~
Grant SeLecT, UPDATE ON MY_TAGBLE TS Some_ustR, A
b. Reveke:-
Tt is used to. take bock permissions from the
user
UTransaction Conkol Language *-
"TEL commands can only use with DML Commands
Vike INseRT, DELETE and VPDATE only.
*COMMIT _ © ROLL BACK + SAVE POINT
Ge Commit :-
Commit Command iS used to save all transaction]
fo the datubase -
Example?
DELETE [rom Cus Tomers
COHERE AGE -=257
Cormmit:
4 |Rollback: Rollback command ig used To undo
ansactions that have net already been saved te
the database
Syntax =
ROLLO Acc
C. Save PoTNT:-
Tk is used to tel the ansachon bacle ty a certain
Potnt twidhout rolling back enlive tansaclion,
Syntaxt-
SPVEPOTNT SAVEPOTNT —NAME
DATA Query LANGUAGE !-
DAL is Usecl to felch the data fom the clotub-|
ase.
O SELECT
a- select: This is Same ag dhe |arosection operati-
on of relational alyeliora. TA is used to select
dhe akbubule based on dhe condition
Syntax *~ SELECT xpress 10ns
FRom Taretes
WHERE conditions ;
Fallow For More
(a) he —Progpammmning: in|
PDE uploded on lelegiam, Source ~ Javatpoint-
Q 7