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

Data Definition Language (DDL) Commands Integrity Constraints

Uploaded by

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

Data Definition Language (DDL) Commands Integrity Constraints

Uploaded by

Ravichandran B
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

EX.

NO: l
DATE: DATA DEFINITION LANGUAGE (DDL)
OS I l ,,. ' COMMANDS AND INTEGRITY
CONSTRAINTS

AIM:
To execute and verify the Data Definition Language commands and Integrity
constraints in RDBMS

PROCEDURE:

SQL: Structured Query Language isa nonproced4ral language used for storing and
managing data in relational database management system (RDBMS).

Domain t)1pes in SQL:


Definition: Domain is defined as the set of all unique values permitted for an
attribute.
Types:
char(n) (or character(n))
varchar(n) (or character varying)
int or integer, smallint, numeric(p, d)
real or double precision, float(n)
date and time
DDL:
• A Data Definition Language (DDL) is a computer language used to create and
modify the structure of database objects in a database
• The DDL commands are auto-commands i.e., it saves all the changes
permanently in the database
S.no Command Syntax Description

1 CREATE L"\~ ~ ~~ ~~~


(o.Hi'\..~\ ~ e t ) , ( 1 'et1.t\f\~ 0. ~
Ml1·~2 ~t)~ w~~~
o.bl:1~" ~,-,;
2 DROP
~ ½ dh.o() {) f
OtoP tnbie ~;
~ ~
°'
3 ALTER
~ ~ tQ.blQnDII\.€ ~ l > ~ ~o
~ ~~ 'lo.me ctUet o1 ("f'oal~ ~
~(>C')~ ~
4 RENAME
~ b \d--. ~ f)OJT\.€ ~ \i, 1~
'tt, ¾>.) ~ l\o..fflR ; on Qit~~

5 TRUNCATE
\~\U'\£ .~ ~ ~ , . ~½~ 0 - ~
'u' ~ ~ rt)~ ~
~ Go. wtthol.U-
6 DESC
\J eM'. ~flcuY \JQ. i
~~ u,~a D
~ ~ ~ O~ew tti~
(.,.,Lt 0.
Integrity Constramts
• Integrity constraints are used to ensure accuracy and consistency of data in a
relational database
• Data integrity is handled in a relational database through the concept of
referenti al integrit) .
• Many types of integrity constraints play a role in referential integrity (RI)
Primary Key Constraints
• Primary key is the term used to identify one or more columns in a table that
make a row of data unique.
• Althoug h the primary key typically consists of one column in a table, more
than one column can comprise the primary key
• The primary key is assigned at table creation in any of the following two forms.

The followin g example identifies the EMP _ID column as the PRIMARY KEY for
the EMPLOYEES table : (The primary key in this case is an implied constraint).

CREATE TABLE EMPLOYEE_TBL


(EMP_ID CHAR(9) NOT NULL PRIMARY KEY,
EMP_NAME VARCHAR (40) NOT NULL,
EMP_ST_ADDR VARCHAR (20) NOT NULL.
EMP_PHONE INTEGFR(l0) NULL);

Primary key can be specificd a~ an explicit constraint when setting up a table, as


follows:
CREATE TABLE EMPLO1 EI TBL
(EMP _ID CHAR(9) \07 f\ l ILL,
EMP _NAME V ARCHAR (40) NOT NULL.
EMP_ST_ADDR VARCHAR( 20) NOTNULL,
EMP_PHONE INTEGER(IO) NULL, PRIMARY KEY(EMP_ID));

d by either of th c
A primary key that consists of more than one colum n can be define
following methods:
To define a PRIMARY KEY al table lcvcl(Composite Primary Key):

CREATE TABLE EMPL OYEE TBL


(EMP_ID CHAR(9) NOTNULL,
EMP_NAME VARCHAR (40) NOT NULL ,
EMP_ST_ADDR VARCHAR(20) NOTNULL,
EMP_PHONE INTEGER(! 0) NULL,
PRIMARY KEY (EMP_ID ,EMP_PHONE));

To create a PRIMARY KEY constraint on table that already exists:

ALTER TABLE EMPLOYEE_TBL_NEW


ADD CONSTRAINT EMP- PK PRIMARY KEY (EMP- ID);
Unique Constraints
for every row of
• It is similar to a primary key in that the value in that column
data in the table must have a unique value
constraint
• Although a primary key constraint is placed on one column, unique
use as the
is specified on another column even though it is not actually for
primary key

Example:
CREATE TABLE EMPLOYEE TBL
(EMP_ID CHAR(9) NOTNULL PRJMARYKEY,
EMP_NAME VARCHAR (40) NOT NULL ,
EMP_ST_ADDR VARCHAR(20) NOTNULL,
EMP_PHONE INTEGER(l0) NULL UNIQUE);

Foreign Key Constraints


ry key in the
• Afore ign key is a column in a child table that references a prima
parent table
e referential
• A foreign key constraint is the main mechanism used to enforc
integrity between tables in a relational database
n defi ned as a
• A column defined as a foreign key is used to reference a colum
primary key in another table
E,3m ple:
LRL ·\TE IAB LE£ ~IP LO\ [E P.--\\ TBL
,E\l P_ID CHAR(Q) "-OT '\l LL.
PCSiTIOX \ ARCHAR2t 15) ~OT "\t LL
DATE HIRE DATE XlL L
P:\ Y R .\ TE :\"l \ffiE RvL !) ~OT )..TLL.
D..\ ;f_L -\~T _RA ISE DATE )..l_LL
co~ ~T R.\ L,, '£\tP_ID_FI~ FOR EIG
~ KE \ (E~fP_ID) REFERE'\CLS
E.\1PLO'iEE_TBL \E~IP_ID))~

EM? lOYE E_~y_TEL


erpl d Foragn
J:,osaior. Keo,
c!a?.e_~ e
rr.cr _r~:= P3) rate
a:1:1-ess ca1e_1ast...rarse
~,
ChJd
Z::'.l
T~
i;..-o7'~
~:;;-~~

.\ ~-,"reign ke~ can be adde d to a table usin


g the ALT ER TAB LE com man d. as show
in ;...~e f Hewing ex.ample: n
-\.l TER TAB LE E\IP LOY EE PAY TBL
- -
ADD CO ~ST RA ~1 ID FK FOREIG
N KEY (EMP_ID) REFERENCES
E\1P LOY EE_ TBL (EM P _ID);

"OT :'.\TLL Constraints


• As mentioned in abov e tables use the
keyv ,ord s 1'HJLL and NOT NUL L liste
')fi the ~ e line as each
d
column and after the data type
• ,OT ~1.JLL cons train t will not allow
the NULL Yalues in spec ified column.
NUL L is gene rally the default for a colu
mn
Che ck Con srra ints : Che ck (CH K) cons
traints can be utilized to chec k the vali dity
data ente red imo part icul ar table colu mns of

Example:
CREATE TABLE E\1PLOYEE_TBL
1E\ IP ID CHA R(9) NOT Nl.JLL,
E\IP \"A~1E V.A.RCHAR2(40) N0T NU LL
E\lP =ST _AD DR YAR CHA R2(2 0) ~0T
NU LL
HvfP llP NUMBER(5) NOT NULL.
PAY RA TE NUMBER( 4,2) NOT NULL,
EMP _PHONE NUMBER(lO) NULL, PRIMARY KEY (EMl'_ID),
CONSTRAINT CHK_EMP_Z IP CHECK ( EMP_ZIP = '46234');

• Check constraint to verify multiple values


CONSTRAINT CHK_EMP_ZIP CHECK ( EMP _ZIP in ('46234'.'46227','46745') );

• Check a column of values with some conditions then the Query:


CONSTRAINT CHK_PAY CHECK ( PAY_RATE > 12.50) ):

Dropping Constraints
• An) constraint that you have defined can be dropped using the ALTER TABLE
command with the DROP CONSTRAINT option
• To drop the primary key constraint in the EMPLOYEES table, you can use the
following command:
ALTER TABLE EMPLOYEES DROP CONSTRAINT EMPLOYEES_PK;
(Or)
ALTER TABLE EMPLOYEES DROP PRIMARY KEY;

DDL Commands:

I. Create a table PRODUCT with the attributes product id. vendor id. product name, price,
quantity.
Query:
CP.EA1E t:~ p-totlu.tJ:;; t P ~ - td.. LIU:: , \Jemloi)l.,.. ~ Lf\k / Pfoelut t-~

~ (.So J , PJut.e \.AA , ~~ ~ ) i

2. Write a Query to add an attribute '·Name of the vendor...

Query: l

/4-L'"l ~~ co.l:)J.e. ptodutk A-bt> f'l.c,.,.n-\.e,_o~-th.e.-Uet\d-oi \Jcthchoh C~¢);

3. Write a Query to change any attribute name.


I
Query: '
f\~1ER l::clbLe P"fe>d.t.u:k 121=.Nijm ~ ~Lu.mi' Pi MU,.\,tb- n.o..m,e t::o ; ~ "llrrll
4. Write a Qu ry to delete any attribute.
0

Query:
~\..1Ef< 6~ Pioduci- t>Ror {ow.mo \)~ ~ - \t:l ;
5. Change the name of the existi ng table.

Query:

Rttvf \ITTG P'1 ~ \::c b'u J..- ~\~ '.,


.
6. Delete the table witho ut affec ting the structure.
Query:

"TR\)n}(~'1E \:DJoLe. '()'Ll}..._clebtl.U, I

7. Delet e the table inclu ding the structure.


Query:

t)~p bl.be but detn ilh~

Integrity Constraints:
1. Write a Quer y to set prima ry key for the
suitab le attribute for the produ ct table .
Query:
(:, ~ ~ l>'t &~ 1- ( , ()"i' o~t~ ~ I {rt oclutt noftl e UM.cl--ort C.n;,
f>'tte_ \M-l ~ •tf2k, ~f\V" (o.iA A- ~l:11
pi ·~ ~ t ()"t~elutt-\c.l )) ;
2. Create a table VEN DOR _DET AILS and establish refere
nce to PRO DUC T table.
Query:
t"i- e~ ~ '\)~i l ~~~ \lo.n~C-m'>, \)e,J.z,"f \d-- tft.(.,,.
Pio c4,u::h6 ~ , c~ l"'\h) 't ~n,t ~ \ t\.O"f ei'~ ~tn i,d .u. .cH J\~
~
P't "~~ c pt~d.m:\.- \ll~\ ; .
3. Appl y the check const raint for any attribute.

Quer y:

~ ~ \)iOch,..tl-1.. ~ t ~ t P'tod»-tt \&- ro) · /


table.
4. Create a primary key with more than one attribute for the PRODUCT
Query:

~ ~ ~d,.w --~ c,..t}d-- {)l''lf'Mh,y \~ ( f't~~ ,d I


1)1' i, d..u.ct- n()./)\R);

4. Write a Quer) to delcre the primary key constraint.


Query:

6. Rela-x the ~:dread) ex isting integrity constraint.


Qu ery:

Additional Questions:
, age,phone
I Create a tab le person with the following attributes Name of the person
no,adhar id. address.
Query:

C1€ £u: e~ f)eJt~f\-de!.61 Lb ( na.rrve l.)ah.t hlh l.5o) ,o..gQ 'Jlk: )

pht,neno W:- ,ad.htu,_ u:l lnk- 1~.S Vci>i..thtt,, l ~ 0 ) ) ,'

2. Change the domai n t ) pe and size for any of the attribute.


Query :

/i L1t:f2. \:ti.\ue pe>at,r,_ ~ th rnocll~ ODfl'l..e thatl (~) j


3. Write a query to delete the defined constraint on lhe table.
Query:

cuw,

4. Add a constraint for an) attribute whose values should not be empty.
Query:

5. Apply the appropriate constraint for any attribute such that it should not accept any
duplicate values.
Query:

\et.bJ.e. P~n _d.,eh,JU:, ~ Lu1Jll.ie (tAdha.,~ __ ,d).I

RESULT
Thus the data definition language commands and integrity constraints were
successfully executed and verified in RDBMS.

MARK ALLOCATION
CONTINUOUS INTERNAL ASSESSMENT
Conduct of Experiment (20)
Record & Result (15)

Viva (15)
--
Total (SO)
·-
Signature of the Faculty with Date
-- - ·-
DDL (om~ (OLLcput) ·.

i ~ \Q\o_\..e l~l~'n.te~

No..fTuQ.
- --
f\) 1..1.il '? , ~re
~
---- ,__ - -·
PlcJ..lU: b - ~iel f\.J.u.m,b-e>, <38 )

\J ~ ~" - u:J-_ n) u..mb~, ( :?.B)


~ 'fMt.Lc ~ flNN'. Ucl)i.Ch:th "l L',())

P0t.tue. ~~ \ ( ~ ")

(lµa.n)::_'L~ f\A.lrnb eh C~ )

:J. 7:n.b.LQ.. C\lte'L~


NCU"n,,Q_ f\JUJA '! ~cfe
........ -- - - -.... - - - r-.--
T--

P't~lu.t:L uel ru.v,..t,,~ (1~)

Ue~~ uJ-._ n..w-,-J:>m C98 '>

~ Cci. u.d-,.J"I~ WS\.(Nln ?...f S--0 \

p~ f\,\J..rn.h 0\. C~8'>

Y\UJ{\b eY\ C. '3 ~ \


~-~
\) QfU1.[U'_ (1(}.fr\,f> \J M&Oh..1 Cro?

:3 , ~ ~ n.uu ': ~s-~~.


"~- -
--- -- -.
nt.l.rnY.> Q)-\. C~c9 '\
P\}u,J.u..d:-- ~
~ & t t~&>>
\) ~ - ~
\lcrncron 'Ltm >
~ - n.<1.J1lJe
fUUl'\,b ~ C?B >
{>~

OJ>ON~
~~ c,~>
\\ffi"t thoJ\ Cl [ ~o )
\f ~ - f\D.ffl.E:
4~ '"1C\.b!J0 0-1.t&-fld

N(\jn~ {Ut_U ')


- - - - ... - .. - ---
~\l:k._\.J__ (\IJPVO Qr\ ( ~ )

\>i~ (lw1.Q \IOSlC~ 1 (St>)

~'Ul:£ ~ ' O f \ t~~')

~ ( 1 .) )
L'lJ-_\l\n.td~
\) ~V\t\CII.TT - f1Clll"'-e
\lot1Ch® 2 Cso)

5 ~ct.bl() '1'f'J1o.-~

() l"~b-Le t:'fll..f\ a,J:-e,d\


7_ l"'-Q-U? ~PPed.

~q,u~ tt'n>.t-trutt.h (o~u.t..,-=


i .. °1£LbJ..Je t~

d ,0-.bue. c~
3 'l:~ ~

l+ - "lnh>-£ ~
s- '\~ ~~
(ill._~ J-
~- 7Qhl£

M.tl..h:~rGl ~~r'\S l o\.ll~ ') ;

l \~ ( ~

NQm.R.
.....__ - .... ,-..,
fUul,..,
- - _:_~
tvDJYLR \)~(_~~

~t%')
~
p'f'O<U' _{)O m.vro~ t~\
Ao.clhan ~1J.. \lcl}-1.c)'O.h(~)

~().)-\~(~)
9~5
?.. . f'tlo.me n,I.JJJ?
--T~'('
...... ,..

vohcJ1W1 r ro)
f\lC\.YT1J{\
t'Ul i1lJo 'th rg~)
re-e
ruuno~-, tg___,)
~~ft(? .(\O
l hx, ( C(l'i)
Virulhl\.)\_ tJ nl01 mm L
\) cu '('h..Q)i LsD)
~rlthl.Eb~

3. ,ctblQ Cl l tE'Af' J--

y_ D t-Sc y0U"O 0
~~
nlctr11,e__ r\WJ 1
-- - --
\jar-t&on ()())
ru~
fU.trrJ:, 'eh t <3» )
~
~ Qi\ C~)
?\on£ .SW
fi\)Cl1 n)Ull
c)vv"\. c. t+ ~ ')
A rul\-m,_fi,l-
\JOS\. ChDY\ (.)())
{)\~)

c5 ,Clble ~ -
EX.NO: 2 DATA MANIPULATION LANGU AGE (DML),
DATE:
IU0Z/i1
DATA CONTR OL LANGUAGE (DCL) AND
TRANSACTION CONTR OL LANGU AGE
(TCL) COMMA NDS

AJM
To study the various DML, DCL and TCL commands and implement them on
the database.

PROCEDURE
Data Manipulat ion Language

• DML is used to Query: and manipulate the existing database objects


• D:t\1L commands are not auto-comm itted. It means changes are not permanent
to database
• They can be rolled back

Command Syntax Descriptio n

Insert to.bleruun.,,e_ ~~ 0... new ie.~


~ lf\tO

\J o.1u.eb t \)Q\u.,e_ \ I \} 6J..l>..e 2_ I ~ • • • J


'-"- d.~C,lb e
\J o.lu.e (\ ) ;

Select
~
~eu:-\. On
{<,'e.-l.ile.Ueb
5~-1- ,e_u--u,rn \:..o..hl_e.n c'.l)-(1R
tr4'm do l:el::nhe,
Update :.v1 r\.n__9
~ ~hl.en.ClJ'"\.E? &ek- mocli~y 'Q 1 ~ Vi
C.Ow.mna.me_ ::. ~, \ l ~ '1 w ~ Q, ta.hle
' ' lond:t tld n "
Delete O~--e ~~ ~ OeLe}-,e.h w Q.X..~tv1g
Whet-e C('.)lLu-nfl '1 CUYt.€ ~ I \Jl\.lu-e 'I 1fuJ~ .

Data Control Language


• The DCL language is used for controlling the access to the table and hence
securing the database
• 1)('1. ;, 11~1..'d tn prn vitk u :: rtn111 pri vikge"I to u p~1rticular U<:;cr. Privileges aru
1·ight~ lw 11llnc,ll l:d

Pri\'ik~l'"
--
l)cscription
------
command
<;,-nnt c~1.'lllf\l- Pi,\J \..l~Ml"J)1e Nl :t\: u, LU:,.e,d l~ g tu e P& IJfU C,S,
~1' \Jh~• l(H'< I'(' l l'I l '11 ())\ nru,r,(> • lo Hl-0 u>.,,q)\ lo Cltc£'.).S H·w cloJ.A
~f\ \ h,e__Ji,_~_Q_ - - - -
(x,e t~H,Q f)'1'll)d~~Q ~1(\ , Tl,Q c,n .., \.:- ( ,S, l Lb <'rJ. fi) Vfo ~J:?.mt.R

----------
l t\_b u. nMn e l1Ju,r"
1
Lili€.WlM fle , PW\JTl.J S 5\on rp~n, ~ CJ.bet'!.

Tr:msaction Control Language


• rhc TCl . languug.c is used Lo manage Lhc changes made by DML statements
• 1t allo,\ S statements to he grouped toge ther into logical transactions

Command Syntax Description


Commit
tornmi \::; ' \f\,Lh ~ I.J.hQtk to 3a,oe 0--ll
I

~e ~ "'iolU,D-.Cl::u:, r,

Rollback RO\.\.~; Coi) ~ ~ hl ed.- to u..n.d. n f-h.€

~~R l-c> ~U~\,r1.,l: , t1~o()), -{tnt {.Sf1 , ~ 0JJ1~U4


~eo..
Sa,epoint
<;~i, lJ1.k 5ili.l Q{)DUl.,l:-flfuf!.e , :D.:- Sek£. °'- Su__uefb w- vi oi...

t:1C\..tu::.o..ct:U,r? Wh.m\ ; ~µ-.n e.d. .

QUERIES:
DATA l\1ANI PULATJON LANGUAGE

I.Describe the table PRODUCT used in EX.NO.I


~ -- - - - -- - - - - - - -- - - -- - - -- - - - - - - - - ~
Query:
D\:.-$t f' -fod.u.ti: ·,

INSERT
j ~- Write a quer) to add live r;wn.ls to the existing table PRODUCT.
Query: r'1be\.fl:: IJU.O Pi~ \h.lJJ...eb l I , , ~ 1 ~00 1 It- J ;
1
' Pe;i
1

r.o.bt'l1..l Ulln { ) \ ~ \Jrw.1.J..Qh C '.l. '- Peru:.lt' , !2 oo , t:>o, 1., ");


vv.ie)J: VU-0 P,<'d.4d: ~ ( 6 I t ~ \ (,('.('.)' ,~ I ~Jj
~ tfl\;O f)1£'d.u.t"l \){1ll.lw.:i ( 'l I tflll~b(J'l.l;? ', ~ CIO t 2,$ 0 I IO) i

VU)e)u: ·~
tl'fcru~c..t \.l:.tllJ,Q).) L c:, , U10fOIJ'l.,t-Q, "" , 1'..Z-0 1 ..,_ J •

3. Insert a new record for only 3 attributes.


Query:

~ \JU:O P1 ocllu:t:- ( t d. ' n (JJ")1R ' P1 ·tt~.e > \Ja.1.u.eb ( , o , l lrlJ:2 ' , ~ a )
3. A company has introduced three new products. Add its details using a single insert
statement.
Query:
~ .vtko "1~ \hJ-u..€h ( ~ '1 0 I 'cf rJ~ f/ <f VI D 1 el p i ~ I cf QWVLtti-y ),,

4. Insert NULL and default values for any two attributes


Query:
'I.ID~ \1\1-o ptM.U..tk (.1 O 1\I t 1) , ~ u:..e , ~~) \nlU€.b l ! O 1)..J 1 I ,f9oo, S ) i

SELECT
1. Display all the records in the product table.
Query:

s~
.
i'-8noff1 pto~;

2. Display any two columns of the table in descending order of product price.
Query:
Eie.1.xvd:. Pf~_(lru
.$~ no.m.e / C\_JJ.OJU:~ ~,r,. ~ Oicleh~ pilte_ o--el>C~
3. Display the attribute values of a table with in a particular price range.
Query:

5eJ.Rtk ~~rn p1~ \,j~ pi'u:e ~ 1..So CL~


5oo . I
4. Di:--pl.0 1hr d~·tu il~of th~ prc~uc-ttahfc,vhosc attribu te vaJ_u~_ar_e_N
_U
_ L_L_. - - - - - - - 1
Q u~-r~ : - - - -- - -

~f'."lQ r l ~ {\J\f\r 1 Pi~ u.rl t u ~ o'.!l f 5 ru·u.1... ,

- - - - - - _ £ - - --------:----:-::-~---;-~----:-;---,
5. Displn) onl) the llrsl l'ft r~cords from the tab le by converting NULL value to the
sric1.:i1kd , ..,luc".
Qucr~:

(\ It

~~ P,l\l\.J..l:k ~Q.\:- Q_l.,lOJUt.t-'1 !:; J. LUh.eiue. Q,lJ.OJ1JL~ -:. 11.Jl}t-L. ;

~CLQ.a- t ~Ort'\ p-to{tLl:t- 1.0~ "1 Ott)fl wn L =5 i


(1. Cn:m~ a quer) to calculate total bill amount.
Qucr~:

~eL'2d:: S.lLfll ( Pi tee ') E\)u,m p-utl.u.ct:- i

7. Display the table in the given format


Product id Product name Rate Quantity Price Vendor id Vendor name
Query:

~Q.lfil ~ '{10fil.J() I f>iU:.e CU-to.nt·LNJ Iv~ -,d


I ~ rn pi~d.u.rc:k- .j

lPDATE
1. Copy the content of the product table in a new table and update the rate of all products
b) 2%.
Que11:

~ ~ ~ p\'~ ~ ( f)tlc,e ~ ('1/c~ 'i ..\- p-1~ '

'1
Write a SQL statement to increase the rate of those products by 50 rs whose rate is less
than 500 rs.
Query:
'l,\ftlnle. f>i~Lu.a- 5.ot ptu,e ':,
Pitt.€ ;- So w heuQ ( f!(\.Clf> L 5o o)~
3 ts. 15% on grocer y on
· Write an SQL query to give 20% reduction on medicinal produc
5 % reduct ion on stationary.
Query :

U.Rit.u-e P i ~ Sel l)i\.re ~ <:~


Ujhm P, \.ce ~ ~ f)ilt:e (Piu:€ ~ 0 · I? ')

W h,er\ Pi'Lt:te. t. 25c, ~ri Pi vr,e _ ( f>h.o() ~ o,o !L )

m(' p-{'\.tt &-\a-. ;

4. Consi der that today is book vendors birthday , add one to his AGE.
Query :

DELETE
1 Elimin ate the produc t which has minimum price.
Query:
~ &telf'7 Pt£riurl- wh.eu Q r1v:.e ~ l ~ rrun (Pf~ >
~ P1~-);

15% GST.
2. It's time for budget cuts. Remove a11 products which have more than
Query :

~ t))\or n (J)1od..u.cl- w~ ~l::: >1S '

3. Write a query to remov e any of the referenced coJumns.

Query :
\:.eu)l._,Q i>iMJ.utl: ~p ul. I.
~
DCL COMMANDS

GRANT

1. Admin wants to share his database to the public and also allow them to update his
database.
Query:

~'"tCHlk- ~---e ~ P"f rlw:l- L-o Pu.bl.f c. ·,

2. Vendor2 wants to share his database to the public and allow them only to view his
database.
Query:

~'10Af- ~~ D0 P--toc!.wo-.- to f>u.bLf t.. •,

REVOKE

1. Vendor2 wants to revoke select plivileges of database from public.


Query:

"\Ql)a_~ ~-- en Ptoo.utl- e,J-lbrr7 p u.bu,, C ·,

2. Admin wants to revoke all privileges of database from public.


Query:

"'\~ ().1).. on P'f t,d.uJek te) Pu.bit, (_ ~

TCL COMMANDS

COMMIT
1. Make the changes done in the transaction permanent.
Query:
ROLLBACK

l. Restore the 1.,t~ of the database to the last commit point.


Query:

SAVEPOlNT

l. Specif:, a point in a transaction to which later you can roll back.


Query:

Additional Questions:

1. Create a banking database with the necessary attributes to maintain the balance and
loan details in separate tables.
Que~·:
t _ ~ 6:uil.e. ~ pJ •lfU:- r no.rn;e Lh)-1 Cttll.)'"\ ( ~o ") ' W-OJ"IIJ..-; fLl- ") r•

{'\~"-'Q_ ~le l.Oc,..J\ ( w uu- t no...tn..R uvichcm ( 2c,) , \ can -Mltl~ '(<U:-) ~

2. Identify the customer having less than the minimal balance and close thejr account.
Que~·:

cleleL---0 ~rn ~ tvrw)tf: b Qi - <1tYtk- L ~OC) ~

3. Appl 1 TCLDCL commands on the table at the appropriate instances.


Quer~:
omi. C.d~ l~).-

f>vM-.ucL~ f\J.J ffV'Jm r 2,,9 )

\) e.ru.l()1 _ ~ f\JJPvb tm r'?><Y )


Pi~clt \.tL(io,ne ucm () h::,J- t r I C> )
P..ru c~ n,wnJP ~"' L1 B )
~~ r\).J.fr\b e\. t 3 & \

d- 5 'i'6LOS C~

3 . \ .-fouJ CJlQ~

4. ~ , ~w.s ( St..eo.J::-e~
Sr ' T ~ ~ -

SeIQet Cou1:fu-tJ ~
P.~-t.ek \)eroc,.n_u:f f n ~ _ rt(lffU2.

!LO O pe_nc; 1

G 600
4-
l
lO
~

s~ .:i_ o

4 ~0 qso
,o
s 7
QI lMLl--l.l~~
~- P1etllltk _ fl(lrruQ

f;~

f"\xi H~ ~ \ L'

ChN.~ \_~ \:-- f' :2


~(LR 'l-

Stcueb 7

P~V\ti \ \'l..
~('.)
r o..peK
&,_i C\b01
4

p1u:R. ~-u~
~ Q,(lolaj,_ ~ P1 ~ f'\().11UQ
P\ ttluc~ -Qi~ (o
?:>Sc
-, 'l_M) f\O~J:<-
q50
~OD (:>~
Lt

4. f\l ~ ~
pi 'u£ ~u~
~-~ P\~~~
5. ~o~~
200 4
p~
l Ob

PE?f\ci l
fDt) lQ
'l dDO

~ ~o ~e}-f
st) 0...t>

q 80
I.+ k_oo f;c,..~

5 roC) ScoJ,Q, 70 7

~- So.,l'\ ( pt u::R.)

\ C\ 00
(. P'tllilltl. \.tJl___ Pi O'lutJ:--f1(\lfV€ P{l___t,Q QJJD-.rtkt~~ \J erdoj\ ~ ~~

Pen 9. ro L\ lo o

<)__
P~n.tt I 6D ,~ fl. cM

b f=.10b't'r\ 2t) 4 l){){j

,...( Dl1J

'~
0~~

c.ho Co \:o1--e
1,SD

l'l_ D
lD
:2_ ~0(9

\0 ('\.J\X<_ \ OC, t)
~D 2.

?> ro.pet-\ So joC)


(2c)

\..t B~ qso ~t!,C,

£"" .3~ 7D 7 s ~~

ltpiate L,~)-.

l . 'Ta.bLQ_ ~
()"\6clu-t°k~ f l ~ ~\..t:,Q_ ct}--l 0-nk'~
Pt~cx\ \j~_c.J_

Lr
t c,~ ·re..n <200 . St'l

l'2.
2-
b
"1
,~
Qot,

.., oo
pQf\ri \

Gv-ctP'el'r
Go. o7
:2o ,0 2 4
\I.D~ ::,fu,3 0 10
& ~M)
Oto Co \.ok-Q 1~.M <)__

\.0 \ ~00
V\P- ~o.Dlf .2
) '100
[-Ofer-\ Sc,, D4 2.o
40D
lf ~ /:\So . \S
3
s -Soo ,Sen.leb tO , \
l
3. LCL\ou€ Lf~cl
Pi ~cllul ·~ u~(l~ - x.J--
I ~ ti 4
2 noo Pt<\c/ I ( ?-

b bc6 dCl--~eh ~

7 ~DO rct'e.-~ ID

.r 8Do e_ h oCD \a.}--'f' l'.lO, D ~


;i.

~o \ ()0 C) •\.n.)12. g}t) · 04


~ ?,co f.=ttr~ StL O ~
I-\- 4~" Ge>-i @in .. ':,

s 56~ SC'O-Leb 713,13

4~ lctbl.JQ. Uf&tl-td'

J ) ~ t.6~~~:

l. "TLLo\JQ ~

~ ~ o.bJJe
r- ~°'
'3. '16.h,lQ ~
.
\\ ~ -\&- pr~..n ~ ~

1..()0
p QI\. '?..C().t--..

~o PQflti \ 60. 0 7 1~
7 ~c) no~ '141 ~ )
t>of) lh~~ l')..t) .. ~J)

l~DO f~
§C ,{) Lt 2
Sa'o POflQ)l Eb . D4
;~ 1.t, ,\:> l
SDt'>
RESULT

fhus the Data M unipulation Language (DML), Data Control Language (DCL)
and Transaction Control Language (TCL) commands were succcssfull: executed and
verified in RDBMS.

MARK ALLOCATION
CONTlNUOUS INTERNAL ASSESSMENT
Conduct of Experiment (20)

Record & Result (15)

Viva (15)

Total (SO)

Signature of the Faculty with Date

You might also like