Untitled

                Never    
SQL
       
// TWORZENIE TABEL 

CREATE TABLE SPECJALNOSC(
     ID_SPEC   NUMBER(4)   CONSTRAINT PK_ID_SPEC PRIMARY KEY,
     NAZWA    VARCHAR2(30)
          );


CREATE TABLE GABINET (
     ID_GABINET   NUMBER(4)   CONSTRAINT PK_ID_GABINET PRIMARY KEY,
     NAZWA    VARCHAR2(30)
     
     );



CREATE TABLE PACJENT (
     ID_PACJENT  NUMBER(4)   CONSTRAINT PK_ID_PACJENT PRIMARY KEY,
     NAZWISKO    VARCHAR2(30),
     IMIE VARCHAR2 (30),
     DATA_UR DATE, 
     MIASTO VARCHAR2 (30)
     );



CREATE TABLE LEKARZ ( 
     ID_LEKARZ     NUMBER(4)   CONSTRAINT PK_ID_LEKARZ PRIMARY KEY,
     NAZWISKO    VARCHAR2(15),
     IMIE        VARCHAR2(15),
     ID_SPEC NUMBER (4) CONSTRAINT FK_ID_SPEC REFERENCES SPECJALNOSC(ID_SPEC)
   
);

CREATE TABLE WIZYTA( 
     ID_WIZYTA   NUMBER(4) CONSTRAINT PK_ID_WIZYTA PRIMARY KEY,
     ID_PACJENT   NUMBER(4) CONSTRAINT FK_ID_PACJENT REFERENCES PACJENT(ID_PACJENT),
     ID_LEKARZ  NUMBER(4) CONSTRAINT FK_ID_LEKARZ REFERENCES LEKARZ(ID_LEKARZ),
     ID_GABINET NUMBER(4) CONSTRAINT FK_ID_GABINET REFERENCES GABINET(ID_GABINET),
     CENA NUMBER (3,2),
     DATA DATE   
     
);


// WSTAWIANIE DANYCH



INSERT INTO SPCJALNOSC  Values (1,  'OKULISTA');
INSERT INTO SPCJALNOSC  Values (2,  'KARDIOLOG');
INSERT INTO SPCJALNOSC  Values (3,  'LARYNGOLOG');
INSERT INTO SPCJALNOSC  Values (4,  'DERMATOLOG');
INSERT INTO SPCJALNOSC  Values (5,  'CHIRURG');


INSERT INTO GABINET Values (1,  'A1');
INSERT INTO GABINET Values (2,  'B1');
INSERT INTO GABINET Values (3,  'C1');
INSERT INTO GABINET Values (4,  'A2');
INSERT INTO GABINET Values (5,  'B2');
INSERT INTO GABINET Values (6,  'C2');



INSERT INTO LEKARZ Values (1,  'Mickiewicz','Adam', 3);
INSERT INTO LEKARZ Values (2,  'S³owacki','Juliusz', 2);
INSERT INTO LEKARZ Values (3,  'Konopnicka','Maria', 1);
INSERT INTO LEKARZ Values (4,  'Tuwim','Julian', 4);
INSERT INTO LEKARZ Values (5,  'Jêdrzejewski','Dariusz', 5);
INSERT INTO LEKARZ Values (6,  'Porter','Eleanor H.', 5);
INSERT INTO LEKARZ Values (7,  'Christie','Agatha', 1);
INSERT INTO LEKARZ Values (8,  'McLaughlin','Michael', 3);
INSERT INTO LEKARZ Values (9,  'Shakespeare','William',2);
INSERT INTO LEKARZ Values (10,  'List','Adela',4);
INSERT INTO LEKARZ Values (11,  'Kamyk','Dariusz',3);
INSERT INTO LEKARZ Values (12,  'Wilczek','Leszek',5);
INSERT INTO LEKARZ Values (13,  'Motyl','Karol',2);
INSERT INTO LEKARZ Values (14,  'Kowal','Adam',4);
INSERT INTO LEKARZ Values (15,  'Palin','Roman',1);


INSERT INTO PACJENT VALUES (1,'KOWALSKI','PIOTR','KRAKOW',to_date('1999/01/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (2,'NOWAK','JAN','WARSZAWA', to_date('2001/07/04','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (3,'ADAMCZYK','PAWEL','WROCLAW',to_date('1995/10/11','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (4,'BRACKI','BOGDAN','JASLO',to_date('2011/01/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (5,'LIPKA','JAKUB','POZNAN',to_date('1991/03/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (6,'IKSIÑSKI','TOMASZ','SANOK',to_date('2011/03/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (7,'NOWAKOWSKA','ANNA','KRAKOW',to_date('2008/01/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (8,'DUDEK','AGATA','WARSZAWA',to_date(1991/05/26','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (9,'GIL','KRYSTYNA','WARSZAWA',to_date('1998/10/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (10,'S£OWIK','WERONIKA','GDYNIA',to_date('2007/02/28','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (11,'LIPKOWSKI','JAKUB','KIELCE',to_date('1991/06/06','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (12,'KOS','TOMASZ','WROCLAW',to_date('2003/11/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (13,'NIWA','ALINA','KRYNICA',to_date('2011/01/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (14,'DARCZ','ALA','TARNOW',to_date('1981/08/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (15,'GALINOWSKI','KAMIL','KALISZ',to_date('2001/05/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (16,'S£OWNA','WIKTORIA','RADOM',to_date('1997/09/13','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (17,'LIS','JAKUB','ZAMOSC',to_date('2001/12/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (18,'BOBER','TADEUSZ','RZESZOW',to_date('2002/07/18','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (19,'NOWACKA','AMELIA','KRAKOW',to_date('1995/09/16','YYYY/MM/DD'));
INSERT INTO PACJENT VALUES (20,'DRACZ','AGATA','PLOCK',to_date('2003/04/02','YYYY/MM/DD'));



INSERT INTO WIZYTA VALUES (1,1,13,3,to_date('2019/01/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (2,1,3,5,to_date('2019/04/08','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (3,4,2,4,to_date('2017/09/10','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (4,4,15,3,to_date('2019/02/30','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (5,6,1,5,to_date('2019/01/10','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (6,5,12,5,to_date('2018/11/27','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (7,2,5,3,to_date('2019/01/01','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (8,1,6,4,to_date('2019/01/02','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (9,6,7,6,to_date('2019/01/15','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (10,1,12,3,to_date('2019/02/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (11,8,11,4,to_date('2019/04/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (12,3,7,5,to_date('2019/01/28','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (13,2,9,4,to_date('2016/03/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (14,6,8,5,to_date('2018/09/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (15,3,3,4,to_date('2018/08/23','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (16,14,15,4,to_date('2016/02/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (17,16,4,5,to_date('2016/01/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (18,7,2,3,to_date('2019/07/19','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (19,2,14,6,to_date('2018/12/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (20,3,3,4,to_date('2019/10/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (21,1,1,3,to_date('2019/02/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (22,18,7,2,to_date('2019/04/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (23,3,1,5,to_date('2019/01/28','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (24,2,6,4,to_date('2019/03/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (25,17,10,6,to_date('2019/09/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (26,8,2,5,to_date('2015/08/23','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (27,20,9,2,to_date('2016/02/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (28,15,13,5,to_date('2016/01/16','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (29,7,5,4,to_date('2015/07/19','YYYY/MM/DD'));
INSERT INTO WIZYTA VALUES (30,2,2,15,to_date('2014/12/16','YYYY/MM/DD'));