SHARE
TWEET

Untitled

a guest Dec 11th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE Stand(
  2. nr_standului int CONSTRAINT pk_nrstand PRIMARY KEY,
  3. numele_vanzatorului varchar2(30) CONSTRAINT nn_numele NOT NULL,
  4. telefon varchar2(10) CONSTRAINT nn_telefon NOT NULL
  5. )
  6.  
  7. CREATE TABLE Articole(
  8. cod_articol NUMBER(4) CONSTRAINT pk_cod_articol PRIMARY KEY
  9.                 CONSTRAINT ck_cod_articol CHECK (cod_articol>100),
  10. denumire_articol varchar2(30) CONSTRAINT nn_denumire_articol NOT NULL,
  11. pret number(6,2) CONSTRAINT nn_pret  NOT NULL,
  12. cantitate number(4) CONSTRAINT nn_cantitate NOT NULL,
  13. cod_stand number(3) CONSTRAINT nn_cod_stand NOT NULL
  14. )
  15.  
  16. CREATE TABLE Tranzactii(
  17. cod_tranzactie number(5) CONSTRAINT pk_cod_tranzactie3 PRIMARY KEY
  18.                          CONSTRAINT nn_cod_tranzactie3 NOT NULL,
  19. cod_stand number(3) CONSTRAINT nn_cod_stand3 NOT NULL,
  20. tipTranzactie varchar2(10) CONSTRAINT nn_tipTranzactie3 NOT NULL,
  21. cod_articol NUMBER(4) CONSTRAINT nn_cod_articol3 NOT NULL,
  22. cod_furnizor NUMBER(4) CONSTRAINT nn_cod_furnizor3 NOT NULL,
  23. cantitate number(4) CONSTRAINT nn_cantitate3 NOT NULL,
  24. pret_total NUMBER(6,2) CONSTRAINT nn_pret_total3 NOT NULL
  25. )
  26.  
  27. CREATE TABLE Furnizori(
  28. cod_furnizor NUMBER(4) CONSTRAINT pk_cod_furnizor4 PRIMARY KEY,
  29. nume_furnizor VARCHAR2(30) CONSTRAINT nn_nume_furnizor4 NOT NULL,
  30. adresa VARCHAR2(30) CONSTRAINT nn_adresa4 NOT NULL,
  31. telefon VARCHAR2(10) CONSTRAINT nn_telefon4 NOT NULL
  32. )
  33.  
  34.  
  35. --LEGATURI DE TABELE--
  36. ALTER TABLE Tranzactii ADD CONSTRAINT fk_tranz1 FOREIGN KEY (cod_stand) REFERENCES Stand(nr_standului);
  37. ALTER TABLE Tranzactii ADD CONSTRAINT fk_tranz2 FOREIGN KEY (cod_articol) REFERENCES Articole(cod_articol);
  38. ALTER TABLE Tranzactii ADD CONSTRAINT fk_tranz3 FOREIGN KEY (cod_furnizor) REFERENCES Furnizori(cod_furnizor);
  39. ALTER TABLE Articole   ADD CONSTRAINT fk_articol FOREIGN KEY (cod_stand) REFERENCES Stand(nr_standului);
  40.  
  41. -- CREARE SECVENTA--
  42.  
  43. CREATE SEQUENCE cod_articol_seq
  44. INCREMENT BY 1
  45. MINVALUE 101
  46. MAXVALUE 999
  47. NOCYCLE
  48. NOCACHE
  49. ORDER;
  50.  
  51. INSERT INTO Stand VALUES (1,'Gigel','1234567890');
  52. INSERT INTO Stand VALUES (2,'Marcel','0234567891');
  53.  
  54. INSERT INTO Articole VALUES(cod_articol_seq.NEXTVAL,'hartie',23.67,5,1);
  55. INSERT INTO Articole VALUES(cod_articol_seq.NEXTVAL,'pix',27,100,2);
  56.  
  57. INSERT INTO Furnizori VALUES(1,'Mihai','Craiova','0123556679');
  58. INSERT INTO Furnizori VALUES(2,'Ion','Bals','0123564329');
  59.  
  60. INSERT INTO Tranzactii VALUES(1,1,'numerar',101,1,4,10);
  61. select *from Tranzactii;
  62. INSERT INTO Tranzactii VALUES(1,3,'numerar',101,1,4,10);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top