0% found this document useful (0 votes)
95 views4 pages

Unit 3

Uploaded by

local id
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
0% found this document useful (0 votes)
95 views4 pages

Unit 3

Uploaded by

local id
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
You are on page 1/ 4
Darshan | Units - Database Integrity Constraints Irreltng na Opes What is Constraint? Explain types of Constraints. ols ai aici Seda fl Rey we Aeglaaed HAL ME A ee okt aU BAA SeBSe2 awl aad. 2 eiez aH 2 pt al abel HL; 1. Entity integrity constraints (St-2ll SeZLAAL 3-2 5-2) 2. Referential integrity constraints React SeAbILA 4238-2) Noman Poa CeO orees rdconad UNIQUE KEY Pome Panay ras INTIGRITY rtd ORACLE CONSTRAINT: Not Null constraint 8 aa ey nda “liz Sole’, GL or “diz slit? oa ey 30 aru 98s Ae al ot 3, oF Ae 3 2a0u8 not mull ale Rats Ha B Adley ae at dee fo ait wate & Fame det B Aa HE ley Haze Gusta) Al ee H OA AS we AE AB A Reo Al Rey oes a aS a, ¢ syntax: COLUMNAME DATATYPE (SIZE) NoT NULL © Example CREATE TABLE ACCOUNT (AN CHAR(3), BALANCE NUMBER (9) NOT NULL, BRANCH VARCHAR2 (10) )7 © aL usied 2a Hoi2 sal outs ov Boa ai aU AAA ta fl Fla ai da ey ed seatati dual di a Bae oeib2 22. owed ouuell Wa Wed al id Zoe WAG ia a dai ass all Zid Faw A not null a2 Bete a4 Be dl Ad Gaus a wa aol as, © Example ALTER TABLE DEPARTNENT MODIFY (DEP_ID NUMBER(2) NOT NULL) ; TT] DEP: ce Dams (3330703) Prof. Akash N. Siddhpura Darshan | 5 - Database Integrity Constraints Irreltng na Opes Check constraint bea dd Gulla loa ot onan seal a ee, ALAA ole 3B o olla nt f Genser: AS we Se ousiGre wi Aca WALA a alll ATL 8, ct See we al OAL 0 FS we Fate wiz silat 2a 4 Slam df Gist tail 9 Ay eaZe2 Oh oy a Flam BHA ous id di, 9 Ay sere arcane wal ou, orn ual Boe AL Lar Sead ona ooil2 al al au seBsee BAL oe3. © ARS Sean aa Va Hla Alege Al & AL Aa aera Sela vse aD ova @ Syntax: COLUMNNAME DATATYPE (SIZE) CHECK (CONDITION) © Example CREATE TABLE ACCOUNT (ANO CHAR(3),BALANCE NUMBER(9) CHECK ( BALANCE >=0 ), BRANCH VARCHAR2 (10)) 7 9 Ae shee lL wil 1 AAS we sted flat 2a ona sl aU B 9 Ay saeihee wis Adds diosa Sailan dd oS 9 Ae saaiee Silleye anil wa ewe AB, fo oenik at See ave RAL A A tl MAUL UL AL GUL AA AL Ea SIRE LO constraint violated” AB. - “check og Satuell WER RA AL AD Bone one GU AA AM MU AL AD Se A As aed Rata se dea AL Gaus ou atm ao a © Example ALTER TABLE DEPARTMENT MODIFY (DEP_ID NUMBER (2) CHECK (DEP_1D>0)); Unique Constraint oul ai Ad 2a dl AS Ae ae gee stpbea di Guile EB. 2 ofA Fea A bis Rate ee ae dla gl i sed al Syntax: COLUMNNAME DATATYPE (SIZE) UNIQUE * Example CREATE TABLE ACCOUNT (ANO CHAR (3) UNIQUE, BALANCE NUMBER (9), BRANCH VARCHAR2 (10) ) 5 9 oA SiS Fle A Ales Catt aed oa da gab 8 a 2 RB, oS wate wis seat AAR gree Rey ed 2B. oe SatUell WER eA AL AD Bote ine GU AA A AU AL AS Dea Bee AL Ad Sense ou a ar a © Example: ALTER TABLE DEPARTMENT MODIFY (DEP_ID NUMBER (2) UNIQUE); iy al at 224 NA LauSeditiand HS2d4 wea dia ead a 124 ie pee a ell Wig NULL AY AD tL Se seg 2] DEP: CE Dams (3330703) Prof. Akash N. Siddhpura D Darshan Unit 5 - Database Integrity Constraints Irreltng na Opes Primary key Constraint © PRIMARY KEY = NOT NULL + UNIQUE 9 Sky ara Ss seat aie Blam Al ays 3 Gea we al yA BA aU ete BAA weed A stawli we 8. FAS By Blam wi oA wvOK A arvana AL AA Reus AL Bal BAB OE OAL Se sean aA Ble re aval J ounant a Aaa aries wrod Lazavil aA, © Fe Fea Aviad A al Matda sata AEB A Dea wi gia Bey did ell 9 Awl aa Bey HL dl ae, ‘Syntax (Simple Key): COLUMNNAME DATATYPE (SIZE) PRIMARY KEY © Example 1, CREATE TABLE ACCOUNT (ANO CHAR(3) PRIMARY KEY, BALANCE NUMBER (9), BRANCH VARCHAR2 (10); 2, ALTER TABLE DEPARTMENT MODIFY (DEP_ID NUMBER(2) PRIMARY KEY) ; Eo SS ed PARTMENT DEPNAME VARCHAR? 20 v - OEP INTIAL VARCHAR? _ 5 v z DEED _ NUMBER 2 0 7 - SUS Zoe Mi Ss sel BR MeREL AL AL GEL, on ts Rell Wie Sia UR MePLEL AL state Ged dl eae meal SLA Bate Aare Ue oy Reidel sel WE B, Maat OU wsteril uewUeL AL Zoe Saiz seal Gt AR oy BEL We B, Bora Siz HL Oe ALTER suis ell aliade weedl anual av vil, * Syntax (Composite Key) : CONSTRAINT NAME_OF_CONSTRAINT PRIMARY KEY (COLUMN1, COLMN2,.., COLUMNn) © Example CREATE TABLE STUDENT_DETAILS ( STU_ID NUMBER(3), STU_NAME VARCHAR2 (30), STU_EN_NO VARCHAR2(12), DEP_ID NUMBER (2), CONSTRAINT PK_STU_ID STU DEP_ID PRIMARY KEY (STU_ID,DEP_ID)); Es a ed Gan wegen se 3] DEP:ce Dams (3330703) Prof. Akash N. Siddhpura Darshan | 5 - Database Integrity Constraints Irreltng na Opes Foreign Key Constraint > Bea 1A wells SAMA seailee wo seawil a B, oA 2 Ba A opave ade 3. RA ALA he ue Se seat Pa Hla UL ayes 3 A allen Be AL wpwdl AL erat dl yas AL ve Al > a sellezeall sl AaB, > di okt dee Boe, det Bot él child Bote seal aD. > Arne ni uve fl rau ae B A Bod A wall Bo, areas Bae ser Tee Bora seal aH 8. > child Boe wet alsa: Y Child te wi Zia $l aul Ua B aA A eee Bova UL sae oe dB. ¥ child? ct ae AL dl Rey Seah aunt oz at WB AA Stealidla Aey We Baa ai dtl iA AU UA Ay A Sea ae ane i HA el, > ee Be went aflett Y eee Sona wi wel AL aaa de 5, % AA Child Zoe aide dle A dle 2B, Vere Bova wil suite al Ale a Al aaeUTAUE AA Ase AL VaL Child Baa Hl AANA AB, Y Child 2a teat wea eee Bora eg (Gade) we id ASA > Syntax: COLUMNNAME DATATYPE (SIZE) REFERENCES TABLENAME (COLUMNNAME) [ON DELETE/UPDATE CASCADE] >» Example CREATE TABLE ACCOUNT (ANO CHAR (3), BALANCE NUMBER (9), BRANCH VARCHAR2 (10) REFERENCES BRANCH_DETATL (BRANCH)); © ON DELETE CASCADE Y ON DELETE CASCADE 44d dla eA dal 5126 ovale wrze Zora iell Ftd al Mele seat Hi BU A aoidl Hy2ei Wel at Child 294 Hi MAL Grea oil BURA Jledle ad wr Bb. © ONUPDATE CASCADE ¥ ON UPDATE CASCADE aid tt a da sie ovuie alee Zora will 5 Wel we seat wi BL AA aotdi eel WL 221 Child 2a Hi BAL ci a ol BUA Bez ad HB. a] DEP: ce Dams (3330703) Prof. Akash N. Siddhpura

You might also like