-- baza danych definiowana w skrypcie
-- PERPEKTYWY
-- rozmaite zagadnienia i pomysly na aktualizacje perspektyw

create table Pamietnik (
  nr 		number(3) 	primary key,
  podpis 	varchar(30)	default user not null,
  tresc		varchar(28)	not null,
  data_wpisu	date 		default sysdate not null 
);

grant select on Pamietnik to public;

create or replace view PamietnikDoWpisow as
  select nr, tresc
    from pamietnik;

grant insert, update, delete, select on PamietnikDoWpisow to public;

create or replace view PamietnikCoPokazujeDodatnie as
  select nr, tresc
    from pamietnik
    where nr > 0;

grant insert, update, delete, select on PamietnikCoPokazujeDodatnie to public;

create or replace view PamietnikDoWpisowDodatnich as
  select nr, tresc
    from pamietnik
    where nr > 0
  with check option constraint tylkoDodatnie;

grant insert, update, delete, select on PamietnikDoWpisowDodatnich to public;

create or replace view TylkoMojeWpisy as
  select nr, tresc
    from pamietnik
    where podpis = user;

grant insert, update, delete, select on TylkoMojeWpisy to public;
