oracle_ry_seata.sql 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 global_table
  20. (
  21. xid VARCHAR2(128) NOT NULL,
  22. transaction_id NUMBER(19),
  23. status NUMBER(3) NOT NULL,
  24. application_id VARCHAR2(32),
  25. transaction_service_group VARCHAR2(32),
  26. transaction_name VARCHAR2(128),
  27. timeout NUMBER(10),
  28. begin_time NUMBER(19),
  29. application_data VARCHAR2(2000),
  30. gmt_create TIMESTAMP(0),
  31. gmt_modified TIMESTAMP(0),
  32. PRIMARY KEY (xid)
  33. );
  34. CREATE INDEX idx_status_gmt_modified ON global_table (status, gmt_modified);
  35. CREATE INDEX idx_transaction_id ON global_table (transaction_id);
  36. -- the table to store BranchSession data
  37. CREATE TABLE branch_table
  38. (
  39. branch_id NUMBER(19) NOT NULL,
  40. xid VARCHAR2(128) NOT NULL,
  41. transaction_id NUMBER(19),
  42. resource_group_id VARCHAR2(32),
  43. resource_id VARCHAR2(256),
  44. branch_type VARCHAR2(8),
  45. status NUMBER(3),
  46. client_id VARCHAR2(64),
  47. application_data VARCHAR2(2000),
  48. gmt_create TIMESTAMP(6),
  49. gmt_modified TIMESTAMP(6),
  50. PRIMARY KEY (branch_id)
  51. );
  52. CREATE INDEX idx_xid ON branch_table (xid);
  53. -- the table to store lock data
  54. CREATE TABLE lock_table
  55. (
  56. row_key VARCHAR2(128) NOT NULL,
  57. xid VARCHAR2(128),
  58. transaction_id NUMBER(19),
  59. branch_id NUMBER(19) NOT NULL,
  60. resource_id VARCHAR2(256),
  61. table_name VARCHAR2(32),
  62. pk VARCHAR2(36),
  63. status NUMBER(3) DEFAULT 0 NOT NULL,
  64. gmt_create TIMESTAMP(0),
  65. gmt_modified TIMESTAMP(0),
  66. PRIMARY KEY (row_key)
  67. );
  68. comment on column lock_table.status is '0:locked ,1:rollbacking';
  69. CREATE INDEX idx_branch_id ON lock_table (branch_id);
  70. CREATE INDEX idx_lock_table_xid ON lock_table (xid);
  71. CREATE INDEX idx_status ON lock_table (status);
  72. CREATE TABLE distributed_lock (
  73. lock_key VARCHAR2(20) NOT NULL,
  74. lock_value VARCHAR2(20) NOT NULL,
  75. expire DECIMAL(18) NOT NULL,
  76. PRIMARY KEY (lock_key)
  77. );
  78. INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
  79. INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
  80. INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
  81. INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
  82. CREATE TABLE vgroup_table
  83. (
  84. vGroup VARCHAR2(255) PRIMARY KEY,
  85. namespace VARCHAR2(255),
  86. cluster VARCHAR2(255)
  87. );