P. 1
uvod_u_SQL.pdf

uvod_u_SQL.pdf

|Views: 7|Likes:
Published by wormbl
sql
sql

More info:

Published by: wormbl on Apr 09, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/09/2013

pdf

text

original

Kad su podaci nepotrebni moramo ih izbrisati. Oni koji su navikli raditi u

:LQGRZV 26 WUHEDOL EL SULSD]LWL MHU QHüH ELWL QLNDNYLK GRGDWQih pitanja
WLSD MHVWH OL VLJXUQL" 2SüHQLWR NDG VDP UDGLR X HGLWRULPD WD MH QDUHGED

uvijek stajala kao komentar – DELETE FROM WHERE.. da je ne bi

L]YUãLR VOXþDMQR 3D EL SUHSRUXþLR GD VH SUYR XYMHW VWDYL X SELECT tako
GD YLGLPR ãWR üHPR REULVDWL LOL GD UDGLmo sa BEGIN TRANSACTION,
COMMIT
i ROLLBACK. 7UDQVDNFLMD R]QDþDYD MHGQX FMHOLQX SRVOD þLML

SRþHWDN R]QDþDYDPR VD BEGIN TRANSACTION i kad završimo tu cjelinu
provjerimo da li je sve u redu, ako je u redu izvršimo COMMIT i

promjene koje smo napravili na bazi SRVWDMX YDåHüH LOL DNR QHãWR QLMH

onako kako smo zamislili izvršimo ROLLBACK i svi podaci su isti kao

SULMH L]YUãHQMD SRþHWND WUDQVDNFLMH
Naredba DELETE QH PRåH REULVDWL YULMHGQRVW L] MHGQRJ SROMD YHü

uklanja cijeli red, moramo paziti da nam se ne javi problem zbog relacije

RVQRYQL VWUDQL NOMXþ L QD NUDMX RYD QDUHGED EULãH VDPR UHGRYH QH L WDEOLFX

Primjer brisanja tablice osoba koja je vezana na tablicu posudi.

Primjer 59:

DELETE FROM osoba

Server: Msg 547, Level 16, State 1, Line 1

DELETE statement conflicted with COLUMN REFERENCE

constraint ’FK__posudi__osoba__3B75D760’. The conflict occurred in database

’mobitel’, table ’posudi’, column ’osoba’.

The statement has been terminated.

61

Ovaj problem rješavamo tako da prvo obrišemo tablicu posudi u kojoj

postoji kljXþ NRML MH YH]DQ QD WDEOLFX RVRED =QDþL þLWDYX WDEOLFX EULãHPR

tako da navedemo samo ime tablice.

Primjer 60:

DELETE FROM posudi;

DELETE FROM osoba;

SELECT * FROM osoba;

(5 row(s) affected)

(5 row(s) affected)

maticni ime prezime ulica mjesto

--------------- --------------- --------------- ------------------------- ---------------

(0 row(s) affected)

.DR L GRVDG NRULVWHüL XYMHW WHERE PRåHPR REULVDWL VDPR QHNH UHGRYH X

tablicama npr. sve osobe koje su iz Zadra.

Primjer 61:

SELECT * FROM osoba WHERE mjesto =’Zadar’;

DELETE FROM osoba WHERE mjesto =’Zadar’;

SELECT * FROM osoba WHERE mjesto =’Zadar’;

maticni ime prezime ulica mjesto

--------------- --------------- --------------- ------------------------- ---------------

0305972383915 Marko Maric Lavova 67 Zadar

(1 row(s) affected)

(1 row(s) affected)

maticni ime prezime ulica mjesto

0 row(s) affected)

62

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->