create_table.db 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. -- 日志表
  2. create table l_transaction_log(
  3. log_id varchar(30) not null COMMENT 'id',
  4. transaction_id VARCHAR(36) NOT NULL COMMENT '外部交易流水',
  5. contract_id varchar(64) not null comment '上下文ID',
  6. ip varchar(20) not null comment '日志产生主机IP',
  7. port varchar(10) not null comment '日志产生端口',
  8. src_ip varchar(20) comment '调用方IP',
  9. src_port varchar(10) comment '调用方端口',
  10. app_id varchar(30) not null comment '调用方应用ID',
  11. user_id varchar(30) comment '用户ID',
  12. service_code varchar(50) comment '服务编码',
  13. service_name varchar(50) comment '服务名称',
  14. timestamp TIMESTAMP NOT NULL comment '日志交互时间,时间戳',
  15. cost_time int not null default 0 comment '耗时',
  16. status_cd varchar(2) not null comment '交互状态 S 成功 F 失败',
  17. month INT NOT NULL comment '月份',
  18. create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  19. unique KEY (log_id,month)
  20. )
  21. partition BY RANGE (month) (
  22. partition transaction_log_1 VALUES LESS THAN (2),
  23. partition transaction_log_2 VALUES LESS THAN (3),
  24. partition transaction_log_3 VALUES LESS THAN (4),
  25. partition transaction_log_4 VALUES LESS THAN (5),
  26. partition transaction_log_5 VALUES LESS THAN (6),
  27. partition transaction_log_6 VALUES LESS THAN (7),
  28. partition transaction_log_7 VALUES LESS THAN (8),
  29. partition transaction_log_8 VALUES LESS THAN (9),
  30. partition transaction_log_9 VALUES LESS THAN (10),
  31. partition transaction_log_10 VALUES LESS THAN (11),
  32. partition transaction_log_11 VALUES LESS THAN (12),
  33. partition transaction_log_12 VALUES LESS THAN (13)
  34. );
  35. -- 日志原始内容表
  36. create table l_transaction_log_message(
  37. log_id varchar(30) not null COMMENT 'id',
  38. request_header LONGTEXT COMMENT '请求头信息',
  39. response_header LONGTEXT COMMENT '返回头信息',
  40. request_message LONGTEXT comment '请求报文',
  41. response_message LONGTEXT comment '返回报文',
  42. remark varchar(200) comment '备注',
  43. month INT NOT NULL comment '月份',
  44. create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  45. UNIQUE KEY (log_id,`month`)
  46. )
  47. partition BY RANGE (month) (
  48. partition transaction_log_message_1 VALUES LESS THAN (2),
  49. partition transaction_log_message_2 VALUES LESS THAN (3),
  50. partition transaction_log_message_3 VALUES LESS THAN (4),
  51. partition transaction_log_message_4 VALUES LESS THAN (5),
  52. partition transaction_log_message_5 VALUES LESS THAN (6),
  53. partition transaction_log_message_6 VALUES LESS THAN (7),
  54. partition transaction_log_message_7 VALUES LESS THAN (8),
  55. partition transaction_log_message_8 VALUES LESS THAN (9),
  56. partition transaction_log_message_9 VALUES LESS THAN (10),
  57. partition transaction_log_message_10 VALUES LESS THAN (11),
  58. partition transaction_log_message_11 VALUES LESS THAN (12),
  59. partition transaction_log_message_12 VALUES LESS THAN (13)
  60. );