28,02,2010 SQL.txt

(1 KB) Pobierz
create table przedmioty(ident integer primary key,
nazwa_przedmiotu varchar(40) not null,rygor char(1),
check (rygor='E' or rygor='Z'));

########## F5 kasacja ##########

insert into przedmioty 
values (1, 'Hurtownia dancyh','E');
select * from przedmioty;

insert into przedmioty 
values (2, 'Matematyka','Z');
select * from przedmioty;

insert into przedmioty 
values (5, 'Historia','E');
select * from przedmioty;

########## F5 kasacja ##########


alter table przedmioty add l_godzin integer;

########## F5 kasacja ##########

select * from przedmioty;

########## F5 kasacja ##########


update przedmioty set l_godzin=16
where ident=1;
select * from przedmioty;

########## F5 kasacja ##########

update przedmioty set l_godzin=30
where l_godzin is null;
select * from przedmioty;

########## F5 kasacja ##########

create table nauczyciele(
id_nauczyciela integer primary key,
nazwisko varchar(20) not null,
imie varchar(10), data_ur datetime,
data_zatr datetime, check(data_ur< data_zatr),
id_przedmiotu integer references 
przedmioty(ident));


########## F5 kasacja ##########

select * from przedmioty;

########## F5 kasacja ##########

insert into nauczyciele
values(1,'Nowak','Jan','19660322','20081111',2);

########## F5 kasacja ##########

insert into nauczyciele
values(2,'Kowalski','Adam','1966-03-22',
'2008-11-11',5);

########## F5 kasacja ##########


delete from przedmioty;

########## F5 kasacja ##########

delete from przedmioty where ident=1;
select * from przedmioty; 

########## F5 kasacja ##########

delete from nauczyciele;
select * from przedmioty; 

########## F5 kasacja ##########

delete from przedmioty;
select * from przedmioty; 

########## F5 kasacja ##########

drop table nauczyciele;
drop table przedmioty;

########## F5 kasacja ##########



Zgłoś jeśli naruszono regulamin