SHARE
TWEET

Untitled

a guest Dec 8th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table marki
  2. (markaId number(5) constraint marka_pk primary key,
  3. nazwa varchar2(15) not null,
  4. opis varchar2(15) not null,
  5. rokPowstania date not null);
  6.  
  7. create table producenci
  8. (producentId number(5) constraint producent_pk primary key,
  9. nazwa varchar2(15) not null,
  10. siedziba varchar2(15) not null,
  11. roczneObroty number(16,2) not null);
  12.  
  13. create table kolory
  14. (kolorId number(5) constraint kolor_pk primary key,
  15. nazwa varchar2(15) not null,
  16. rgb varchar2(15) not null);
  17.  
  18. create table samochody
  19. (samochodId number(5) constraint samochod_pk primary key,
  20.  
  21. marka_Id number(5),
  22. producent_Id number(5),
  23. kolor_Id number(5),
  24.  
  25. constraint marka_fk_id foreign key (marka_Id) references marki (markaId),
  26. constraint producent_fk_id foreign key (producent_Id) references producenci (producentId),
  27. constraint kolor_fk_id foreign key (kolor_Id) references kolory (kolorId),
  28. rokProdukcji date not null);
  29.  
  30. create sequence s_marki
  31. increment by 1
  32. start with 1
  33. order;
  34.  
  35. create sequence s_producenci
  36. increment by 1
  37. start with 1
  38. order;
  39.  
  40. create sequence s_kolory
  41. increment by 1
  42. start with 1
  43. order;
  44.  
  45. create sequence s_samochody
  46. increment by 1
  47. start with 1
  48. order;
  49.  
  50. insert into marki values (s_marki.nextval,'BMW','Bemki',to_date ('11/11/1974','dd/mm/yyyy'));
  51. insert into marki values (s_marki.nextval,'Opel','Opelki',to_date ('02/11/1976','dd/mm/yyyy'));
  52. insert into marki values (s_marki.nextval,'Mazda','Mazdy',to_date ('03/09/1977','dd/mm/yyyy'));
  53. insert into marki values (s_marki.nextval,'VW','Wagen',to_date ('02/01/1987','dd/mm/yyyy'));
  54. insert into marki values (s_marki.nextval,'Audi','Audice',to_date ('05/12/1954','dd/mm/yyyy'));
  55.  
  56. insert into producenci values (s_producenci.nextval,'Producent 1','Lorem Ipsum',22200);
  57. insert into producenci values (s_producenci.nextval,'Producent 2','Warszawa',23200);
  58. insert into producenci values (s_producenci.nextval,'Producent 3','Porto',42200);
  59. insert into producenci values (s_producenci.nextval,'Producent 4','Nicea',62200);
  60. insert into producenci values (s_producenci.nextval,'Producent 5','Manchester',72200);
  61.  
  62. insert into kolory values (s_kolory.nextval,'Czarny','0,0,0');
  63. insert into kolory values (s_kolory.nextval,'Bialy','255,255,255');
  64. insert into kolory values (s_kolory.nextval,'Czerwony','255,0,0');
  65. insert into kolory values (s_kolory.nextval,'Niebieski','0,255,0');
  66. insert into kolory values (s_kolory.nextval,'Zielony','0,0,255');
  67.  
  68. insert into samochody values (s_samochody.nextval,1, 1, 1,to_date ('02/01/2019','dd/mm/yyyy'));
  69. insert into samochody values (s_samochody.nextval,2, 2, 2,to_date ('02/01/2019','dd/mm/yyyy'));
  70. insert into samochody values (s_samochody.nextval,3, 3, 3,to_date ('02/01/2019','dd/mm/yyyy'));
  71. insert into samochody values (s_samochody.nextval,4, 4, 4,to_date ('02/01/2019','dd/mm/yyyy'));
  72. insert into samochody values (s_samochody.nextval,5, 5, 5,to_date ('02/01/2019','dd/mm/yyyy'));
  73.  
  74. SELECT * FROM samochody;
  75. SELECT * FROM marki;
  76. SELECT * FROM producenci;
  77. SELECT * FROM kolory;
  78.  
  79. UPDATE samochody SET rokProdukcji = to_date ('30/12/2030','dd/mm/yyyy') WHERE samochodId = 3;
  80. ALTER TABLE samochody ADD dataPrzegladu date;
  81. UPDATE samochody SET dataPrzegladu = to_date ('10/11/2010','dd/mm/yyyy');
  82.  
  83. SELECT * FROM samochody;
  84.  
  85. drop sequence s_marki;
  86. drop sequence s_producenci;
  87. drop sequence s_kolory;
  88. drop sequence s_samochody;
  89.  
  90. drop table marki cascade constraints;
  91. drop table producenci cascade constraints;
  92. drop table kolory cascade constraints;
  93. drop table samochody cascade constraints;
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