mysql.sql 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. --
  2. -- Licensed to the Apache Software Foundation (ASF) under one or more
  3. -- contributor license agreements. See the NOTICE file distributed with
  4. -- this work for additional information regarding copyright ownership.
  5. -- The ASF licenses this file to You under the Apache License, Version 2.0
  6. -- (the "License"); you may not use this file except in compliance with
  7. -- the License. You may obtain a copy of the License at
  8. --
  9. -- http://www.apache.org/licenses/LICENSE-2.0
  10. --
  11. -- Unless required by applicable law or agreed to in writing, software
  12. -- distributed under the License is distributed on an "AS IS" BASIS,
  13. -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. -- See the License for the specific language governing permissions and
  15. -- limitations under the License.
  16. --
  17. -- -------------------------------- The script used when storeMode is 'db' --------------------------------
  18. -- the table to store GlobalSession data
  19. CREATE TABLE IF NOT EXISTS `global_table`
  20. (
  21. `xid` VARCHAR(128) NOT NULL,
  22. `transaction_id` BIGINT,
  23. `status` TINYINT NOT NULL,
  24. `application_id` VARCHAR(32),
  25. `transaction_service_group` VARCHAR(32),
  26. `transaction_name` VARCHAR(128),
  27. `timeout` INT,
  28. `begin_time` BIGINT,
  29. `application_data` VARCHAR(2000),
  30. `gmt_create` DATETIME,
  31. `gmt_modified` DATETIME,
  32. PRIMARY KEY (`xid`),
  33. KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),
  34. KEY `idx_transaction_id` (`transaction_id`)
  35. ) ENGINE = InnoDB
  36. DEFAULT CHARSET = utf8mb4;
  37. -- the table to store BranchSession data
  38. CREATE TABLE IF NOT EXISTS `branch_table`
  39. (
  40. `branch_id` BIGINT NOT NULL,
  41. `xid` VARCHAR(128) NOT NULL,
  42. `transaction_id` BIGINT,
  43. `resource_group_id` VARCHAR(32),
  44. `resource_id` VARCHAR(256),
  45. `branch_type` VARCHAR(8),
  46. `status` TINYINT,
  47. `client_id` VARCHAR(64),
  48. `application_data` VARCHAR(2000),
  49. `gmt_create` DATETIME(6),
  50. `gmt_modified` DATETIME(6),
  51. PRIMARY KEY (`branch_id`),
  52. KEY `idx_xid` (`xid`)
  53. ) ENGINE = InnoDB
  54. DEFAULT CHARSET = utf8mb4;
  55. -- the table to store lock data
  56. CREATE TABLE IF NOT EXISTS `lock_table`
  57. (
  58. `row_key` VARCHAR(128) NOT NULL,
  59. `xid` VARCHAR(128),
  60. `transaction_id` BIGINT,
  61. `branch_id` BIGINT NOT NULL,
  62. `resource_id` VARCHAR(256),
  63. `table_name` VARCHAR(32),
  64. `pk` VARCHAR(36),
  65. `status` TINYINT NOT NULL DEFAULT '0' COMMENT '0:locked ,1:rollbacking',
  66. `gmt_create` DATETIME,
  67. `gmt_modified` DATETIME,
  68. PRIMARY KEY (`row_key`),
  69. KEY `idx_status` (`status`),
  70. KEY `idx_branch_id` (`branch_id`),
  71. KEY `idx_xid` (`xid`)
  72. ) ENGINE = InnoDB
  73. DEFAULT CHARSET = utf8mb4;
  74. CREATE TABLE IF NOT EXISTS `distributed_lock`
  75. (
  76. `lock_key` CHAR(20) NOT NULL,
  77. `lock_value` VARCHAR(20) NOT NULL,
  78. `expire` BIGINT,
  79. primary key (`lock_key`)
  80. ) ENGINE = InnoDB
  81. DEFAULT CHARSET = utf8mb4;
  82. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
  83. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
  84. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
  85. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
  86. CREATE TABLE IF NOT EXISTS `vgroup_table`
  87. (
  88. `vGroup` VARCHAR(255),
  89. `namespace` VARCHAR(255),
  90. `cluster` VARCHAR(255),
  91. UNIQUE KEY `idx_vgroup_namespace_cluster` (`vGroup`,`namespace`,`cluster`)
  92. ) ENGINE = InnoDB
  93. DEFAULT CHARSET = utf8mb4;