create_table.db 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. -- 日志表
  2. create table l_transaction_log(
  3. log_id varchar(30) not null keY unique COMMENT 'id',
  4. transaction_id VARCHAR(30) 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. status_cd varchar(2) not null comment '交互状态 S 成功 F 失败',
  16. month INT NOT NULL default month(CURRENT_DATE) comment '月份',
  17. create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  18. PRIMARY KEY (log_id)
  19. )
  20. partition BY RANGE (month) (
  21. partition transaction_log_1 VALUES LESS THAN (2),
  22. partition transaction_log_2 VALUES LESS THAN (3),
  23. partition transaction_log_3 VALUES LESS THAN (4),
  24. partition transaction_log_4 VALUES LESS THAN (5),
  25. partition transaction_log_5 VALUES LESS THAN (6),
  26. partition transaction_log_6 VALUES LESS THAN (7),
  27. partition transaction_log_7 VALUES LESS THAN (8),
  28. partition transaction_log_8 VALUES LESS THAN (9),
  29. partition transaction_log_9 VALUES LESS THAN (10),
  30. partition transaction_log_10 VALUES LESS THAN (11),
  31. partition transaction_log_11 VALUES LESS THAN (12),
  32. partition transaction_log_12 VALUES LESS THAN (13)
  33. );
  34. -- 日志原始内容表
  35. create table l_transaction_log_message(
  36. log_id varchar(30) not null unique FOREIGN KEY REFERENCES l_transaction_log(log_id) COMMENT 'id',
  37. request_header LONGTEXT COMMENT '请求头信息',
  38. response_header LONGTEXT COMMENT '返回头信息',
  39. request_message LONGTEXT comment '请求报文',
  40. response_message LONGTEXT comment '返回报文',
  41. remark varchar(200) comment '备注',
  42. month INT NOT NULL default month(CURRENT_DATE) comment '月份',
  43. create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
  44. )
  45. partition BY RANGE (month) (
  46. partition transaction_log_message_1 VALUES LESS THAN (2),
  47. partition transaction_log_message_2 VALUES LESS THAN (3),
  48. partition transaction_log_message_3 VALUES LESS THAN (4),
  49. partition transaction_log_message_4 VALUES LESS THAN (5),
  50. partition transaction_log_message_5 VALUES LESS THAN (6),
  51. partition transaction_log_message_6 VALUES LESS THAN (7),
  52. partition transaction_log_message_7 VALUES LESS THAN (8),
  53. partition transaction_log_message_8 VALUES LESS THAN (9),
  54. partition transaction_log_message_9 VALUES LESS THAN (10),
  55. partition transaction_log_message_10 VALUES LESS THAN (11),
  56. partition transaction_log_message_11 VALUES LESS THAN (12),
  57. partition transaction_log_message_12 VALUES LESS THAN (13)
  58. );