GSD Questions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
4.3 KiB

7 years ago
  1. SET FEEDBACK OFF
  2. DROP TABLE T1 CASCADE CONSTRAINTS;
  3. DROP TABLE T2 CASCADE CONSTRAINTS;
  4. CREATE TABLE T1 (A INT, B INT, C INT, CONSTRAINT T1_PS PRIMARY KEY (A,B), CONSTRAINT T1_SK UNIQUE (C));
  5. CREATE TABLE T2 (A INT, B INT, C INT, D INT, E INT, CONSTRAINT T2_PS PRIMARY KEY (A), CONSTRAINT T2_FS1 FOREIGN KEY (B,C) REFERENCES T1(A,B), CONSTRAINT T2_FS2 FOREIGN KEY (D) REFERENCES T1(C), CONSTRAINT T2_E_NN CHECK (E IS NOT NULL), CONSTRAINT T2_E_13 CHECK (E BETWEEN 1 AND 3));
  6. SET FEEDBACK OFF
  7. SET FEEDBACK OFF
  8. DELETE FROM T2;
  9. DELETE FROM T1;
  10. INSERT INTO T1 VALUES (1, 1, 5);
  11. INSERT INTO T1 VALUES (2, 2, 10);
  12. INSERT INTO T1 VALUES (3, 3, 15);
  13. INSERT INTO T1 VALUES (4, 4, 20);
  14. INSERT INTO T1 VALUES (5, 5, 25);
  15. INSERT INTO T2 VALUES (100, NULL, NULL, 15, 1);
  16. INSERT INTO T2 VALUES (101, 2, 2, 25, 2);
  17. INSERT INTO T2 VALUES (102, 2, 2, NULL, 3);
  18. INSERT INTO T2 VALUES (103, 3, 3, 10, 3);
  19. INSERT INTO T2 VALUES (104, 3, 3, 10, 3);
  20. SET FEEDBACK ON
  21. INSERT INTO T1 VALUES (1, 2, 5);
  22. SET FEEDBACK OFF
  23. DELETE FROM T2;
  24. DELETE FROM T1;
  25. INSERT INTO T1 VALUES (1, 1, 5);
  26. INSERT INTO T1 VALUES (2, 2, 10);
  27. INSERT INTO T1 VALUES (3, 3, 15);
  28. INSERT INTO T1 VALUES (4, 4, 20);
  29. INSERT INTO T1 VALUES (5, 5, 25);
  30. INSERT INTO T2 VALUES (100, NULL, NULL, 15, 1);
  31. INSERT INTO T2 VALUES (101, 2, 2, 25, 2);
  32. INSERT INTO T2 VALUES (102, 2, 2, NULL, 3);
  33. INSERT INTO T2 VALUES (103, 3, 3, 10, 3);
  34. INSERT INTO T2 VALUES (104, 3, 3, 10, 3);
  35. SET FEEDBACK ON
  36. INSERT INTO T1 VALUES (1, 2, 30);
  37. SET FEEDBACK OFF
  38. DELETE FROM T2;
  39. DELETE FROM T1;
  40. INSERT INTO T1 VALUES (1, 1, 5);
  41. INSERT INTO T1 VALUES (2, 2, 10);
  42. INSERT INTO T1 VALUES (3, 3, 15);
  43. INSERT INTO T1 VALUES (4, 4, 20);
  44. INSERT INTO T1 VALUES (5, 5, 25);
  45. INSERT INTO T2 VALUES (100, NULL, NULL, 15, 1);
  46. INSERT INTO T2 VALUES (101, 2, 2, 25, 2);
  47. INSERT INTO T2 VALUES (102, 2, 2, NULL, 3);
  48. INSERT INTO T2 VALUES (103, 3, 3, 10, 3);
  49. INSERT INTO T2 VALUES (104, 3, 3, 10, 3);
  50. SET FEEDBACK ON
  51. INSERT INTO T1 VALUES (1, 1, 50);
  52. SET FEEDBACK OFF
  53. DELETE FROM T2;
  54. DELETE FROM T1;
  55. INSERT INTO T1 VALUES (1, 1, 5);
  56. INSERT INTO T1 VALUES (2, 2, 10);
  57. INSERT INTO T1 VALUES (3, 3, 15);
  58. INSERT INTO T1 VALUES (4, 4, 20);
  59. INSERT INTO T1 VALUES (5, 5, 25);
  60. INSERT INTO T2 VALUES (100, NULL, NULL, 15, 1);
  61. INSERT INTO T2 VALUES (101, 2, 2, 25, 2);
  62. INSERT INTO T2 VALUES (102, 2, 2, NULL, 3);
  63. INSERT INTO T2 VALUES (103, 3, 3, 10, 3);
  64. INSERT INTO T2 VALUES (104, 3, 3, 10, 3);
  65. SET FEEDBACK ON
  66. INSERT INTO T1 VALUES (1, NULL, NULL);
  67. SET FEEDBACK OFF
  68. DELETE FROM T2;
  69. DELETE FROM T1;
  70. INSERT INTO T1 VALUES (1, 1, 5);
  71. INSERT INTO T1 VALUES (2, 2, 10);
  72. INSERT INTO T1 VALUES (3, 3, 15);
  73. INSERT INTO T1 VALUES (4, 4, 20);
  74. INSERT INTO T1 VALUES (5, 5, 25);
  75. INSERT INTO T2 VALUES (100, NULL, NULL, 15, 1);
  76. INSERT INTO T2 VALUES (101, 2, 2, 25, 2);
  77. INSERT INTO T2 VALUES (102, 2, 2, NULL, 3);
  78. INSERT INTO T2 VALUES (103, 3, 3, 10, 3);
  79. INSERT INTO T2 VALUES (104, 3, 3, 10, 3);
  80. SET FEEDBACK ON
  81. INSERT INTO T2 VALUES (117, 2, 2, 5, 5);
  82. SET FEEDBACK OFF
  83. DELETE FROM T2;
  84. DELETE FROM T1;
  85. INSERT INTO T1 VALUES (1, 1, 5);
  86. INSERT INTO T1 VALUES (2, 2, 10);
  87. INSERT INTO T1 VALUES (3, 3, 15);
  88. INSERT INTO T1 VALUES (4, 4, 20);
  89. INSERT INTO T1 VALUES (5, 5, 25);
  90. INSERT INTO T2 VALUES (100, NULL, NULL, 15, 1);
  91. INSERT INTO T2 VALUES (101, 2, 2, 25, 2);
  92. INSERT INTO T2 VALUES (102, 2, 2, NULL, 3);
  93. INSERT INTO T2 VALUES (103, 3, 3, 10, 3);
  94. INSERT INTO T2 VALUES (104, 3, 3, 10, 3);
  95. SET FEEDBACK ON
  96. INSERT INTO T2 VALUES (109, 3, 1, 10, 3);
  97. SET FEEDBACK OFF
  98. DELETE FROM T2;
  99. DELETE FROM T1;
  100. INSERT INTO T1 VALUES (1, 1, 5);
  101. INSERT INTO T1 VALUES (2, 2, 10);
  102. INSERT INTO T1 VALUES (3, 3, 15);
  103. INSERT INTO T1 VALUES (4, 4, 20);
  104. INSERT INTO T1 VALUES (5, 5, 25);
  105. INSERT INTO T2 VALUES (100, NULL, NULL, 15, 1);
  106. INSERT INTO T2 VALUES (101, 2, 2, 25, 2);
  107. INSERT INTO T2 VALUES (102, 2, 2, NULL, 3);
  108. INSERT INTO T2 VALUES (103, 3, 3, 10, 3);
  109. INSERT INTO T2 VALUES (104, 3, 3, 10, 3);
  110. SET FEEDBACK ON
  111. INSERT INTO T2 VALUES (103, 1, 1, 20, 2);
  112. SET FEEDBACK OFF
  113. DELETE FROM T2;
  114. DELETE FROM T1;
  115. INSERT INTO T1 VALUES (1, 1, 5);
  116. INSERT INTO T1 VALUES (2, 2, 10);
  117. INSERT INTO T1 VALUES (3, 3, 15);
  118. INSERT INTO T1 VALUES (4, 4, 20);
  119. INSERT INTO T1 VALUES (5, 5, 25);
  120. INSERT INTO T2 VALUES (100, NULL, NULL, 15, 1);
  121. INSERT INTO T2 VALUES (101, 2, 2, 25, 2);
  122. INSERT INTO T2 VALUES (102, 2, 2, NULL, 3);
  123. INSERT INTO T2 VALUES (103, 3, 3, 10, 3);
  124. INSERT INTO T2 VALUES (104, 3, 3, 10, 3);
  125. SET FEEDBACK ON
  126. INSERT INTO T2 VALUES (110, 4, 4, 35, 1);