Document Details

Uploaded by Deleted User

Onur İNAN

Tags

database programming SQL PL/SQL database design

Summary

This document provides lecture notes on database programming, covering topics such as SQL, PL/SQL, database design, queries, constraints, and indexes. It also contains sample code and examples.

Full Transcript

Veri tabanı programlama Onur İNAN Araçlar: Oracle Express Sürümü https://www.oracle.com/database/technologies/xe-downloads.html https://www.oracle.com/database/technologies/xe-prior-release-do wnloads.html Sql developer yada Pl/Sql Developer Online https://livesql.oracle.com/...

Veri tabanı programlama Onur İNAN Araçlar: Oracle Express Sürümü https://www.oracle.com/database/technologies/xe-downloads.html https://www.oracle.com/database/technologies/xe-prior-release-do wnloads.html Sql developer yada Pl/Sql Developer Online https://livesql.oracle.com/ ORACLE EXPRESS KURULUM ORACLE EXPRESS KURULUM ORACLE EXPRESS KURULUM ORACLE EXPRESS KURULUM ORACLE EXPRESS KURULUM ORACLE EXPRESS KURULUM Create table Foreign KEY create table ogrenci( create table ders( ogrno int, dersno varchar(11) not null, adisoyad varchar(25), dersadi varchar(25), fakulte varchar(25), kredi int, bolum varchar(25), saat int, CONSTRAINT pkkey1 PRIMARY KEY(ogrno)) CONSTRAINT pkkey2 PRIMARY KEY(dersno)) create table derskaydi( ogrno int, dersno varchar(11), vize int, final int, CONSTRAINT fkkey1 FOREIGN KEY(ogrno) REFERENCES Ogrenci(ogrno) on delete cascade, --on update cascade CONSTRAINT fkkey2 FOREIGN KEY(dersno) REFERENCES ders(dersno) on delete cascade) --on update cascade ) Create table otomatik artış (mysql) create table personel( sicil int not null AUTO_INCREMENT=1, ad varchar(25), soyad varchar(25), adres varchar(250), sehir varchar(250), UNIQUE(sicil) ) Sequence Create sequence sequence_adi MINVALUE en_düşük_değer MAXVALUE en_yuksek_değer START WITH ilk_değer INCREMENT BY artis_miktari CYCLE / NOCYCLE İnsert into tablo(sicil,ad,soyad) values (sayac.nextval,’AAA’,’BBB’) Create table Foreign KEY (kütüphane) create table kitap( create table uye( kitapid int not null, uyeno varchar(11) not null, adi varchar(25), adsoyad varchar(25), yazar varchar(25), adres varchar(25), yer varchar(25), tel varchar(25), CONSTRAINT pkkey1 PRIMARY KEY(kitapid)) CONSTRAINT pkkeykut2 PRIMARY KEY(uyeno)) create table odunc( kitapid int, uyeno varchar(11), bastar date, bittar date, CONSTRAINT fkkeykit1 FOREIGN KEY(kitapid) REFERENCES Kitap(kitapid) on delete cascade, --on update cascade CONSTRAINT fkkeykit2 FOREIGN KEY(uyeno) REFERENCES uye(uyeno) on delete cascade, --on update cascade ) ALTER Daha önce oluşturulmuş veri tabanı nesnesinin özelliğini değiştirmek için kullanılır. Yapılmak istenen değişiklik parametre olarak verilir. Ekleme ALTER TABLE tablo ADD sutunadi özellikler Silme ALTER TABLE tablo DROP COLUMN sutunadi özellikler Değiştirme ALTER TABLE tablo ALTER COLUMN sutunadi özellikler Alter ALTER TABLE OGRENCI ADD DOGTAR date not null; ALTER TABLE OGRENCI ADD UNIQUE(BOLUM); ALTER TABLE OGRENCI ADD CONSTRAINT ucde UNIQUE(FAKULTE); ALTER TABLE OGRENCI ADD PRIMARY KEY (OGRNO) Yada ALTER TABLE OGRENCI ADD CONSTRAINT Pk_key PRIMARY KEY (OGRNO,AD) ALTER ALTER TABLE tderskaydi ADD CONSTRAINT fkkey2 FOREIGN KEY(dersno) REFERENCES ders(dersno) on delete cascade ALTER TABLE odunc ADD CONSTRAINT fkkeykit2 FOREIGN KEY(uyeno) REFERENCES uye(uyeno) on delete cascade ALTER TABLE tderskaydi ADD CONSTRAINT chk_tdrs CHECK (not1>0 and not1,

Use Quizgecko on...
Browser
Browser