test-sql-script-mysql.sql 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. CREATE TABLE T_ACCOUNT
  2. (
  3. ID INT NOT NULL,
  4. NAME VARCHAR(20) NOT NULL COMMENT '帐号名',
  5. HEAD_IMG BLOB COMMENT '头像图片',
  6. INTRODUCTION TEXT COMMENT '自我介绍',
  7. PRIMARY KEY (ID)
  8. ) COMMENT='帐号';
  9. CREATE TABLE T_ADDRESS
  10. (
  11. ACCOUNT_ID INT COMMENT '所属帐号',
  12. CITY VARCHAR(50) COMMENT '城市',
  13. STREET VARCHAR(100) COMMENT '街道',
  14. RESIDENTIAL VARCHAR(100) COMMENT '住宅区',
  15. HOUSE_NUMBER VARCHAR(100) COMMENT '门牌号'
  16. ) COMMENT='住址';
  17. ALTER TABLE T_ADDRESS ADD FOREIGN KEY (ACCOUNT_ID) REFERENCES T_ACCOUNT (ID);
  18. ALTER TABLE T_ADDRESS ADD CONSTRAINT UK_ACCOUNT_ID UNIQUE (ACCOUNT_ID);
  19. CREATE TABLE T_ADDRESS_TYPE
  20. (
  21. ID INT,
  22. TYPE_NAME VARCHAR(50) NOT NULL,
  23. PRIMARY KEY (ID)
  24. );
  25. CREATE TABLE T_ADDRESS_MORE
  26. (
  27. ACCOUNT_ID INT NOT NULL COMMENT '所属地址',
  28. ADDRESS VARCHAR(200) COMMENT '地址',
  29. ADDRESS_TYPE INT,
  30. ADDRESS_PHOTO BLOB COMMENT '地址照片',
  31. ADDRESS_DESC TEXT COMMENT '地址描述'
  32. ) COMMENT='更多住址';
  33. ALTER TABLE T_ADDRESS_MORE ADD FOREIGN KEY (ACCOUNT_ID) REFERENCES T_ADDRESS (ACCOUNT_ID) ON DELETE CASCADE ON UPDATE CASCADE;
  34. ALTER TABLE T_ADDRESS_MORE ADD FOREIGN KEY (ADDRESS_TYPE) REFERENCES T_ADDRESS_TYPE (ID);
  35. CREATE TABLE T_PRODUCT
  36. (
  37. ID INT NOT NULL,
  38. NAME VARCHAR(20) NOT NULL COMMENT '商品名称',
  39. PRICE DECIMAL(10,2) NOT NULL COMMENT '价格',
  40. PRIMARY KEY (ID)
  41. ) COMMENT='商品';
  42. CREATE TABLE T_ORDER
  43. (
  44. ID INT NOT NULL,
  45. NAME VARCHAR(20) NOT NULL COMMENT '订单名称',
  46. ACCOUNT_ID INT COMMENT '所属帐号',
  47. DESCRIPTION VARCHAR(20) DEFAULT 'note' COMMENT '描述',
  48. STAR_LEVEL INT DEFAULT 1 COMMENT '星级',
  49. CREATE_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '创建日期',
  50. EDIT_TIME DATETIME COMMENT '编辑日期',
  51. PRIMARY KEY (ID)
  52. ) COMMENT='订单';
  53. ALTER TABLE T_ORDER ADD FOREIGN KEY (ACCOUNT_ID) REFERENCES T_ACCOUNT (ID);
  54. CREATE TABLE T_ORDER_PRODUCTS
  55. (
  56. ORDER_ID INT NOT NULL COMMENT '订单',
  57. PRODUCT_ID INT NOT NULL COMMENT '商品'
  58. ) COMMENT='订单-商品';
  59. ALTER TABLE T_ORDER_PRODUCTS ADD FOREIGN KEY (ORDER_ID) REFERENCES T_ORDER (ID) ON DELETE CASCADE ON UPDATE CASCADE;
  60. ALTER TABLE T_ORDER_PRODUCTS ADD FOREIGN KEY (PRODUCT_ID) REFERENCES T_PRODUCT (ID) ON DELETE CASCADE ON UPDATE CASCADE;
  61. CREATE TABLE T_PRODUCT_PRICE_HISTORY
  62. (
  63. PRODUCT_ID INT NOT NULL COMMENT '商品',
  64. PRICE DECIMAL(10,2) NOT NULL COMMENT '价格'
  65. );
  66. ALTER TABLE T_PRODUCT_PRICE_HISTORY ADD FOREIGN KEY (PRODUCT_ID) REFERENCES T_PRODUCT (ID) ON DELETE CASCADE ON UPDATE CASCADE;
  67. CREATE TABLE T_AUTO_GENERATED_KEYS
  68. (
  69. ID INT NOT NULL AUTO_INCREMENT,
  70. NAME VARCHAR(20),
  71. CREATE_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP(),
  72. PRIMARY KEY (ID)
  73. );
  74. CREATE TABLE `T_PECULIAR_ACCOUNT_[a]b$c`
  75. (
  76. ID INT NOT NULL,
  77. NAME VARCHAR(20) NOT NULL COMMENT '帐号名',
  78. HEAD_IMG BLOB COMMENT '头像图片',
  79. INTRODUCTION TEXT COMMENT '自我介绍',
  80. PRIMARY KEY (ID)
  81. ) COMMENT='帐号';
  82. CREATE TABLE `T_PECULIAR_ADDRESS_[ab]c$d_1`
  83. (
  84. ACCOUNT_ID INT COMMENT '所属帐号',
  85. CITY VARCHAR(50) COMMENT '城市',
  86. STREET VARCHAR(100) COMMENT '街道',
  87. RESIDENTIAL VARCHAR(100) COMMENT '住宅区',
  88. HOUSE_NUMBER VARCHAR(100) COMMENT '门牌号'
  89. ) COMMENT='住址';
  90. ALTER TABLE `T_PECULIAR_ADDRESS_[ab]c$d_1` ADD FOREIGN KEY (ACCOUNT_ID) REFERENCES `T_PECULIAR_ACCOUNT_[a]b$c` (ID);
  91. ALTER TABLE `T_PECULIAR_ADDRESS_[ab]c$d_1` ADD CONSTRAINT UK_ACCOUNT_ID UNIQUE (ACCOUNT_ID);
  92. CREATE TABLE `T_PECULIAR_ADDRESS_MORE_a$b[cde]f_1`
  93. (
  94. ACCOUNT_ID INT NOT NULL COMMENT '所属地址',
  95. ADDRESS VARCHAR(200) COMMENT '地址',
  96. ADDRESS_PHOTO BLOB COMMENT '地址照片',
  97. ADDRESS_DESC TEXT COMMENT '地址描述',
  98. `PECULIAR_new$_t[a]b.lec<ol>1#` VARCHAR(50)
  99. ) COMMENT='更多住址';
  100. ALTER TABLE `T_PECULIAR_ADDRESS_MORE_a$b[cde]f_1` ADD FOREIGN KEY (ACCOUNT_ID) REFERENCES `T_PECULIAR_ADDRESS_[ab]c$d_1` (ACCOUNT_ID) ON DELETE CASCADE ON UPDATE CASCADE;
  101. CREATE TABLE T_DATE
  102. (
  103. ID INT NOT NULL,
  104. `DATE` DATE,
  105. `DATETIME` DATETIME,
  106. `TIME` TIME,
  107. `TIMESTAMP` TIMESTAMP,
  108. `YEAR` YEAR,
  109. PRIMARY KEY (ID)
  110. );
  111. CREATE TABLE T_DATA_IMPORT
  112. (
  113. ID INT NOT NULL,
  114. NAME VARCHAR(200),
  115. COL_DATE DATE,
  116. COL_DATETIME DATETIME,
  117. COL_TIME TIME,
  118. COL_TIMESTAMP TIMESTAMP,
  119. COL_BLOB BLOB,
  120. COL_CLOB TEXT,
  121. PRIMARY KEY (ID)
  122. );
  123. CREATE TABLE T_DATA_EXPORT
  124. (
  125. ID INT NOT NULL,
  126. NAME VARCHAR(200),
  127. COL_DATE DATE,
  128. COL_DATETIME DATETIME,
  129. COL_TIME TIME,
  130. COL_TIMESTAMP TIMESTAMP,
  131. COL_BLOB BLOB,
  132. COL_CLOB TEXT,
  133. PRIMARY KEY (ID)
  134. );
  135. CREATE TABLE T_ANALYSIS
  136. (
  137. NAME VARCHAR(50) NOT NULL,
  138. VALUE DECIMAL(10,2) NOT NULL
  139. );
  140. CREATE TABLE T_ANALYSIS_1
  141. (
  142. COL_NAME VARCHAR(50) NOT NULL,
  143. COL_DATE DATE NOT NULL,
  144. COL_VALUE DECIMAL(10,2) NOT NULL
  145. );
  146. CREATE TABLE T_ANALYSIS_2
  147. (
  148. COL_NAME VARCHAR(50) NOT NULL,
  149. COL_X DECIMAL(10,2) NOT NULL,
  150. COL_Y DECIMAL(10,2) NOT NULL
  151. );
  152. CREATE TABLE T_ANALYSIS_MAP
  153. (
  154. COL_NAME VARCHAR(50) NOT NULL,
  155. COL_VALUE DECIMAL(10,2) NOT NULL,
  156. COL_LONGITUDE DECIMAL(12,6),
  157. COL_LATITUDE DECIMAL(12,6),
  158. PRIMARY KEY (COL_NAME)
  159. );
  160. CREATE TABLE T_ANALYSIS_MAP_1
  161. (
  162. COL_NAME VARCHAR(50),
  163. COL_VALUE DECIMAL(10),
  164. COL_PARENT VARCHAR(50)
  165. );
  166. CREATE TABLE T_TIME_SERIES
  167. (
  168. COL_TIME VARCHAR(50),
  169. COL_VALUE DECIMAL(10,2)
  170. );
  171. /*
  172. truncate table t_auto_generated_keys;
  173. truncate table t_data_export;
  174. truncate table t_data_import;
  175. truncate table t_date;
  176. truncate table t_order_products;
  177. truncate table t_order;
  178. truncate table t_product_price_history;
  179. truncate table t_product;
  180. truncate table `t_peculiar_address_more_a$b[cde]f_1`;
  181. truncate table `t_peculiar_address_[ab]c$d_1`;
  182. truncate table `t_peculiar_account_[a]b$c`;
  183. truncate table t_address_more;
  184. truncate table t_address;
  185. truncate table t_address_type;
  186. truncate table t_account;
  187. truncate table t_analysis;
  188. truncate table t_analysis_1;
  189. truncate table t_analysis_2;
  190. truncate table t_analysis_map;
  191. truncate table t_analysis_map_1;
  192. truncate table t_time_series;
  193. */
  194. /*
  195. drop table t_auto_generated_keys;
  196. drop table t_data_export;
  197. drop table t_data_import;
  198. drop table t_date;
  199. drop table t_order_products;
  200. drop table t_order;
  201. drop table t_product_price_history;
  202. drop table t_product;
  203. drop table `t_peculiar_address_more_a$b[cde]f_1`;
  204. drop table `t_peculiar_address_[ab]c$d_1`;
  205. drop table `t_peculiar_account_[a]b$c`;
  206. drop table t_address_more;
  207. drop table t_address;
  208. drop table t_address_type;
  209. drop table t_account;
  210. drop table t_analysis;
  211. drop table t_analysis_1;
  212. drop table t_analysis_2;
  213. drop table t_analysis_map;
  214. drop table t_analysis_map_1;
  215. drop table t_time_series;
  216. */