create_table.sql 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. --
  2. -- CREATE_TABLE
  3. --
  4. --
  5. -- CLASS DEFINITIONS
  6. --
  7. CREATE TABLE hobbies_r (
  8. name text,
  9. person text
  10. );
  11. CREATE TABLE equipment_r (
  12. name text,
  13. hobby text
  14. );
  15. CREATE TABLE onek (
  16. unique1 int4,
  17. unique2 int4,
  18. two int4,
  19. four int4,
  20. ten int4,
  21. twenty int4,
  22. hundred int4,
  23. thousand int4,
  24. twothousand int4,
  25. fivethous int4,
  26. tenthous int4,
  27. odd int4,
  28. even int4,
  29. stringu1 name,
  30. stringu2 name,
  31. string4 name
  32. );
  33. CREATE TABLE tenk1 (
  34. unique1 int4,
  35. unique2 int4,
  36. two int4,
  37. four int4,
  38. ten int4,
  39. twenty int4,
  40. hundred int4,
  41. thousand int4,
  42. twothousand int4,
  43. fivethous int4,
  44. tenthous int4,
  45. odd int4,
  46. even int4,
  47. stringu1 name,
  48. stringu2 name,
  49. string4 name
  50. );
  51. CREATE TABLE tenk2 (
  52. unique1 int4,
  53. unique2 int4,
  54. two int4,
  55. four int4,
  56. ten int4,
  57. twenty int4,
  58. hundred int4,
  59. thousand int4,
  60. twothousand int4,
  61. fivethous int4,
  62. tenthous int4,
  63. odd int4,
  64. even int4,
  65. stringu1 name,
  66. stringu2 name,
  67. string4 name
  68. );
  69. CREATE TABLE person (
  70. name text,
  71. age int4,
  72. location point
  73. );
  74. CREATE TABLE city (
  75. name name,
  76. location box,
  77. budget city_budget
  78. );
  79. CREATE TABLE dept (
  80. dname name,
  81. mgrname text
  82. );
  83. CREATE TABLE slow_emp4000 (
  84. home_base box
  85. );
  86. CREATE TABLE fast_emp4000 (
  87. home_base box
  88. );
  89. CREATE TABLE road (
  90. name text,
  91. thepath path
  92. );
  93. CREATE TABLE real_city (
  94. pop int4,
  95. cname text,
  96. outline path
  97. );
  98. --
  99. -- test the "star" operators a bit more thoroughly -- this time,
  100. -- throw in lots of NULL fields...
  101. --
  102. -- a is the type root
  103. -- b and c inherit from a (one-level single inheritance)
  104. -- d inherits from b and c (two-level multiple inheritance)
  105. -- e inherits from c (two-level single inheritance)
  106. -- f inherits from e (three-level single inheritance)
  107. --
  108. CREATE TABLE a_star (
  109. class char,
  110. a int4
  111. );
  112. CREATE TABLE aggtest (
  113. a int2,
  114. b float4
  115. );
  116. CREATE TABLE hash_i4_heap (
  117. seqno int4,
  118. random int4
  119. );
  120. CREATE TABLE hash_name_heap (
  121. seqno int4,
  122. random name
  123. );
  124. CREATE TABLE hash_txt_heap (
  125. seqno int4,
  126. random text
  127. );
  128. CREATE TABLE hash_f8_heap (
  129. seqno int4,
  130. random float8
  131. );
  132. -- don't include the hash_ovfl_heap stuff in the distribution
  133. -- the data set is too large for what it's worth
  134. --
  135. -- CREATE TABLE hash_ovfl_heap (
  136. -- x int4,
  137. -- y int4
  138. -- );
  139. CREATE TABLE bt_i4_heap (
  140. seqno int4,
  141. random int4
  142. );
  143. CREATE TABLE bt_name_heap (
  144. seqno name,
  145. random int4
  146. );
  147. CREATE TABLE bt_txt_heap (
  148. seqno text,
  149. random int4
  150. );
  151. CREATE TABLE bt_f8_heap (
  152. seqno float8,
  153. random int4
  154. );
  155. CREATE TABLE array_op_test (
  156. seqno int4,
  157. i int4[],
  158. t text[]
  159. );
  160. CREATE TABLE array_index_op_test (
  161. seqno int4,
  162. i int4[],
  163. t text[]
  164. );
  165. CREATE TABLE testjsonb (
  166. j jsonb
  167. );
  168. CREATE TABLE IF NOT EXISTS test_tsvector(
  169. t text,
  170. a tsvector
  171. );
  172. CREATE TEMP TABLE explicitly_temp (a int primary key); -- also OK
  173. -- check that tables with oids cannot be created anymore
  174. CREATE TABLE withoid() WITH OIDS;
  175. -- but explicitly not adding oids is still supported
  176. CREATE TEMP TABLE withoutoid() WITHOUT OIDS;
  177. DROP TABLE withoutoid;
  178. -- Verify that subtransaction rollback restores rd_createSubid.
  179. BEGIN;
  180. CREATE TABLE remember_create_subid (c int);
  181. SAVEPOINT q;
  182. DROP TABLE remember_create_subid;
  183. ROLLBACK TO q;
  184. COMMIT;
  185. -- Verify that subtransaction rollback restores rd_firstRelfilenodeSubid.
  186. CREATE TABLE remember_node_subid (c int);
  187. BEGIN;
  188. SAVEPOINT q;
  189. DROP TABLE remember_node_subid;
  190. ROLLBACK TO q;
  191. COMMIT;
  192. -- syntax does not allow empty list of values for list partitions
  193. CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN ();
  194. -- check if compatible with the specified parent
  195. -- cannot create as partition of a non-partitioned table
  196. CREATE TABLE unparted (
  197. a int
  198. );
  199. DROP TABLE unparted;
  200. SELECT conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass;
  201. create table defcheck_def (a int, c int, b int);
  202. -- test that complex default partition constraints are enforced correctly
  203. insert into defcheck_def values (0, 0);