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

4pplyi1: Duplcomge Te Me Eniohg

SQL is a programming language used to manage data in relational database management systems. It is used to store, manipulate and retrieve data as well as manage users and permissions. The main components of SQL are DDL, DML, and DCL which allow users to define schemas, manipulate data and manage security respectively.

Uploaded by

Raj Kumar Thakur
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)
127 views

4pplyi1: Duplcomge Te Me Eniohg

SQL is a programming language used to manage data in relational database management systems. It is used to store, manipulate and retrieve data as well as manage users and permissions. The main components of SQL are DDL, DML, and DCL which allow users to define schemas, manipulate data and manage security respectively.

Uploaded by

Raj Kumar Thakur
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/ 17

4PPlyi1 t s operapicn bn relalisn, s

duplcomge te me the
eniohg
relain eo ow CAgAhh
a comge
names oibke br the codten
Cthe dauta Hhe relaiop a n
-
Hocs ever, 1t boible h
e n MS the att ibre as eoell.

eld shod-
stud ent (Reno, shvd od-nan,
parueutaddm
Jt s oleusted y he symbs.
aed oamager gueonov
a

F o ra U 1
A

pbose Hhot eoe


oisk to tind alU evstouwrs
clb ave a acesnt at all the oranehe. tooaf
ed in Brooklm.
e are vem branoh reloon.
branch-voame bremah-iy
BrDoly 71,oo, ooo
oconEOon Brok lyn 9,O6O
ianws Horseneck
AOrth Tocon 37,,OM
ye
hoxee neclc
Perry >id 9e
oona Bennin gbo 3. D,UM
eoduodod alo 41b 4, O0,0O
Kound I| hoTse ede

le are aso ien the fo]lo-oing too elaimo,

CooMer nome cuntuubfr


Hoye -102
Teu soM A 10
Jewso t-2o
inc sa - 2 22
-21
Tumer -30
Sig the debesibr relohau
S-wher.
CotovorervOTUte Bramch naw
Dooutosu STb
au
A- I022
Pemridge
A-30S

2 n gton 3S
A-222
Rdwd 760
A-217
rig ton 7S

tlhe occasu reatioy.


sk P FRd all onchen coiel are docapd in Bdrelf

(Branch)
Brameh dy Broklyu"

Bramonnawe Branch.o sels Becoa


Cig hbu Brstk y 71,00, UD
Don a Brst
Pre echisr
Branchnanne
Bng htovy
Doan toO

SQL.
seFd qt cestouer nae branch - w
ostome hame acoun.

tnahnd
Accowt J
bebos or
Costoer_ naue Hccowt wher Breunel
Penynde e y6D
Ho A102
Doon town StD
Setnugou
usou. A 20
SouO A-207
760
inds Ao2
A-21S Mfanws
Tu
mer Rend

lcstou ts nanP, braudh uaue


Pepost tu A
Cotowea noMe braue nauw
Hoye Pempidge
euasn iqthon
Tone
nd ay Ai-aus Podwad
Roud uMI
doacto > stavdard.

have a
Oho accanf at cultthe branchey
ed Pn bode n
Shetl3'ocaled

Cosome nam
Jenns

SQL.
todu cion ho sql, DOL, DML
-SOL Stauds or sruckured Puery CangLage.
-IE oas eaafer n ouou a SEQUEL Fed
tor s h
caunod enginsn guery laq uage
-IE Ca me o t ts am
M as
-Almos a cowmmerciod BMSs suapoat sQL.
-1is am fudushiaeepo do tue sa d da-
toloase monafemef suteucs
9ue
SQL has eababilibe 7 d e a i ond mamiJatulahms
daaboae
I t h o othhree major en cou
-(DDopa de?nofion.longuage
(PDe)
ore waunpdabou Carguade (RML)
2)
3 Dota cofro laugaqDeL)
s p e i a l y mea
-is apoqraming
auguade
Cang .a7
Enanpulariug
dentg 9ueriny
geuesarou Cang
-lt fs aso ecdes 46L a
fo eseprem aho hes lhe
Oe co oue

equuNS ooa in t h e d o t e b a n e .

Oue coqes Hhat iAs.


needu n k proqram
Jb
s hoo the ueeded zegwremets aae

lae a e l i e e

u e i n Cqaohisn)
Selec none o u Studet oha e (o;PA>

6 vcepa>3S ( s d e)

PL:
Tis combouont SPL hos Hhe cowaut
or ereafPg ateing and esppiug. tales.
sQL uaes He s oad eble gor elcou o
0e aa tuple cnd cafumu or a u atfnbute .

s s e anle chng Hhe halle tit


adoug eoth Ih dabr p aud cousait .)
any, i deincd
eter Consauws tle deraut volue ouny
atbue , nô- nu
primal
eamod eunhy- integn y
rekeoneif amd
q n dre als0 deued DDL.
X
sOtaeuen

DML
ML rovides ceuscs or enfeing,delelina
an wamaaulang, dad-

cL
psovlde cosnck or graatrin a ,
3evo ha authoxiy to ueRS, and Srausathin
wmamg 9ekled-

Creahug ble.

Creafe tabfe talele omnR


(LofumM - uame laa-epe(size):
Coduwm - naul doa pe(vire)a
Cetwwu - naMe 4ala-ypltze )4

table ame Leanp, uameg


Here
Here,
cefuw unmo MeoD na
uM.
NGe: Reloon a >elehal alzea is called
l e in SQL
cauwM iaS0
Atenbule is ealled

pesi-

wwwaes t u deeihal. b.eint ntber

a nd0
e rr
eunt
sinb, uwhos
o t ded mal poink, n g eonoisfa
oharatkers kes chara ckrs plus ubor
+spil dharadeh dae e ,

ox
ind a daka that a coluw
tees
sQLsupbon olihen oloa p ; a e major
dape 0 }llouus:

CHAR

Te dara type allouus fieed Jeugt el


acherd stvn up to 2
enered and stored.

vARCHATR
Tus daakype va iable leugth eharotwr
ing upto 1o00 haracerss fo be
enreed and stoed
NUMBge
TS dal- Fyae cllouus uloers ndu
diung decima peint to e enleed.and

DATE'-
Tis data dype alloos snly dates t
eukered &ne sred, e (Hepld
p m a s P - Mon rrY -

LONG
very ong n g s Counishn
up o 63S3 cha fersfca comse
ehteved nd sored.
so .
det m e a m s wmo

So ALTER saemet io vaed gor moo


Ahe snchure a toble.
aM change l n e i z e a celummm
3
ooe ceuld doye erdey
J t io bessie to add n e Cs{umn a uvel

Sqwtae hor odoung uad s{uus

(Pren enfer
ALTER TABLE TALE _ NAMe>
A pD
(neo. Cafumn name
ldojakappe (tre)
Lneo.elun name> elafa bpe (sYzo)7,

Nee: ohat ooe i l e eaoitth in a aira


ang ar releeks an

s i d e ame t have to he le

Sppesiug ha+ M u ' s srup


ENT l a po
, we co suld Aste G add uoo uerd
C w s - Moter's noume and emai addre
Ts s k cau be aecom p4hed , issug
he keuousua S Sfofemeuf

A A81
ALTER TABLE STUDEAlT ADD.
(Mother -na me v a scha (30), r

Ema address varclha r (3o))

Usg Oroer by eda anse

Order b clauae oleus uo o afaat rt corls


a e aoatelar esluw .Ov-
ou

demig CaM be erHher fa qsceuong ayer


x dseeotng, ordor.
S i siateumet-
selecr * from_sudet;
oldpos at recorcds
studenttable s soafing.
Note * stands gos e iug
seleet o studetoroer t hame dese;

tuden
dislay
oble
u mco>ds om
Ju devendiug order.

cle se: decend A dla do


d
acendg
drle

select * Prom fud eutt order aue


wetting jo menoueabet tH
nce
orde, ituses 4
dedt olieh s cendiy

uppo
padded
° ed Hha CCPA a ues coluMmu aread
.deut
udeut talle, the aloue SQz
satemeid dixploy alre co ds
sudnt table Soafed P deceudn Ozoder
o CCPA . aMd tevm ou nane.

Select krou studet o der by Cgpa, nam


desc;
C-V
lwksgiusralus,
O Pomoln iwkegny Couroiut
sality tak4, CoU r a i n s

Kernkialiugviy conxhalnd

aksqiy- Dakabase meww be hue (cohect) amd


coukistamt
xLousrainbi- Rues thot must be leoed t
dalabaye.
lnkeariy conshroinsta wes Hhaf wut e llb-
Coe sb Hhot dalabase s crseet ox ue aand
md
cso cousi staw

-CenaraPnt deined
arn aA
ulesa i el have Fod
ba. eleoedlu ease os databases Boo, o e hae sel-
,

som sules olieln ha to ae kaleeoed. i e


Vaeuws tpes coushants Hhacam be ciied
e d
rlahool data base schena, fclude
elleuing
) Domain enusraink.
tegri cosfreius
ansralnkr
Consrau
The abeve weuiauedd ecousrainh ax <euial so
e daabase be rue and e u u s t t , a m d an

e called ntegnty cousali.


S10Pauaain (ouuouds e p i t danai
Here, data asociad
cally mdude inkegers, feloafng peiut wwbeK,
e , Hme, shing,el.ReaieoSou tie set
Values o Hheattbue e
can sheshed. e

cousa hukor aledd be cm n e e r bekpeen


O and 999 oara deste iun
maximM wwlkor
the atnbuk Nauue,
ahould Le
Damon ousraint, e o e s otibt
e opaises the deiued, dala tyee and
deiuedsize. for endulsele , in L ,duam
covirauls ar obeod b Creaing table ar
usraeeelop
Croae table shudeud
CRegisraionuuuaor duwber uo).
Naue vaxchar (uo),
Addesa varoar (uo),
Sex vardhar )
Dae- ith dake,
Fathernauevaacdhar(uo
Mether-naue vaarchar (O
YDgraM
varelar (eo));
The abe sqL stafeme hies eacl
astn beue posse
& e.
daa deined d Fipr.

2)Eniy lMRgn (onsrainks,


Hhar each veDo n a
OcuMy iarih
elaioA aan
ceushrai ueutures
quely idoukkid
by m athi bue aled oainary key. h e beiàn
canebe hae a NOLL value..TAs iS be aadaa tHA JK.
canet
ary ke valua ja used o Ideuhy iudivisuo tufples
nla sel&iou. Having nutl values torHhe i may ke
ke
molies thot we cado- ideulby sque t\plea, pora
mple itoo ox mee hod wu Hieir
lway keya ,oe wig uet be able o d i a g i
For A. s
exauole, in seL, entity iteasiy, enorced
ug Hhe sfmao ko Ise Beaia thd fable
shooue/s«o- K
Creae k sprden
(Regisroaiou -nuuber Nwber (o),
Aldme vaachar (uo)
Adeess varcdhar (40),
Sex yarchar (),
Dale-oe -bith
(4),
Dafe
Faher-name varelar (uo),
Noer. noune vercorlus),
trogra vaTchar (ao),
Pwa uwaer )):
leoResbrhe auuae ))
nar, hos
Here,
ee, e a t a u e , Raishason-
Jbeen declayed o- Hhe bmay key a t e Falble
ee.
3Rgezeuia tutepity Coustalats
ai
ourni Ha elaes sos realls and wdns
ConuseuCy acr
Jo4secy acro the relafious To make this clear,
let us eduusider koo relahfous Raud S
let leF PE be
the paima ka R, cwd let Pk also, ae p~ten
S
R,Td Me o h g atbues qelak»
elaios Rand s arerelofed. +Hheu Pk called
oHhe elakon, S.
e
athibufes in korelgn key wu
hesame deuain have
the othíbutes da Hetr
as

baimary respechiue
>ReLereut talegity ewsues ha
fe
value oj Hhe paiumary te evem
lu SQL
rereia inleqny euperced by
deelarinq-foreig be
pximam r e aRiL{es f
colich a table
e.oter tables.
poY exawle, in given SQL s{afement
a
sales-oxder- delalshas been
,
a able
s-0 der- n. tnao ied
order aubere t nteces alle
AsFthe i ,
sales
ke
Cveae able Aale order -deloils
S-Order-no varclar (a),
psotuc- no varchar (6),
u a u i - ordered amber (8),
qua4oispateled wuuaer (Rs),
30duerae uwwber (8,2),
mar ce A-eder -no psoduer-uo),
smay
ereiqa ke0 (S -shder-uo) sepereuee s salererer

ey Coushnigs-
A elaou deued as a ao tples. a
olevafn,al eleueu a set ave diafncr Tis eaus HdlfF
notpes Cau hae Hhe saume counlsinofan a values por cu
their ttbufes.
l u geueral, a elatfonscheua mau ave MOre
thaun eve è .. l u i s coase eatm Hhe ealle keys
Caled a camddaf key. lt is coum& to dosigsafebue q
Hhe eamdloe key3 ashe bimay toy therelaHs
Hhe pmary ke isiuthe ellieg
wndUsu U ncads velaon
a

You might also like