Advertisement
Guest User

Untitled

a guest
May 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. /*==============================================================*/
  2. /* DBMS name: Microsoft SQL Server 2008 */
  3. /* Created on: 07.05.2018 14:20:30 */
  4. /*==============================================================*/
  5.  
  6.  
  7. if exists (select 1
  8. from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
  9. where r.fkeyid = object_id('wiadomosc') and o.name = 'FK_WIADOMOS_RELATIONS_DZIAL')
  10. alter table wiadomosc
  11. drop constraint FK_WIADOMOS_RELATIONS_DZIAL
  12. go
  13.  
  14. if exists (select 1
  15. from sysobjects
  16. where id = object_id('dzial')
  17. and type = 'U')
  18. drop table dzial
  19. go
  20.  
  21. if exists (select 1
  22. from sysindexes
  23. where id = object_id('wiadomosc')
  24. and name = 'Relationship_1_FK'
  25. and indid > 0
  26. and indid < 255)
  27. drop index wiadomosc.Relationship_1_FK
  28. go
  29.  
  30. if exists (select 1
  31. from sysobjects
  32. where id = object_id('wiadomosc')
  33. and type = 'U')
  34. drop table wiadomosc
  35. go
  36.  
  37. /*==============================================================*/
  38. /* Table: dzial */
  39. /*==============================================================*/
  40. create table dzial (
  41. id_dzial int not null,
  42. nazwa_dzial varchar(50) not null,
  43. constraint PK_DZIAL primary key nonclustered (id_dzial)
  44. )
  45. go
  46.  
  47. /*==============================================================*/
  48. /* Table: wiadomosc */
  49. /*==============================================================*/
  50. create table wiadomosc (
  51. id_wiadomosc int not null,
  52. id_dzial int not null,
  53. Imie varchar(50) not null,
  54. Nazwisko varchar(50) not null,
  55. "E-mail" varchar(50) not null,
  56. telefon varchar(50) not null,
  57. tresc varchar(500) not null,
  58. constraint PK_WIADOMOSC primary key nonclustered (id_wiadomosc)
  59. )
  60. go
  61.  
  62. /*==============================================================*/
  63. /* Index: Relationship_1_FK */
  64. /*==============================================================*/
  65. create index Relationship_1_FK on wiadomosc (
  66. id_dzial ASC
  67. )
  68. go
  69.  
  70. alter table wiadomosc
  71. add constraint FK_WIADOMOS_RELATIONS_DZIAL foreign key (id_dzial)
  72. references dzial (id_dzial)
  73. go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement