sqlserver.sql 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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] nvarchar(128) NOT NULL,
  22. [transaction_id] bigint NULL,
  23. [status] tinyint NOT NULL,
  24. [application_id] nvarchar(32) NULL,
  25. [transaction_service_group] nvarchar(32) NULL,
  26. [transaction_name] nvarchar(128) NULL,
  27. [timeout] int NULL,
  28. [begin_time] bigint NULL,
  29. [application_data] nvarchar(2000) NULL,
  30. [gmt_create] datetime2 NULL,
  31. [gmt_modified] datetime2 NULL,
  32. PRIMARY KEY CLUSTERED ([xid])
  33. WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
  34. )
  35. GO
  36. CREATE NONCLUSTERED INDEX [idx_gmt_modified_status]
  37. ON [global_table] (
  38. [gmt_modified],
  39. [status]
  40. )
  41. GO
  42. CREATE NONCLUSTERED INDEX [idx_transaction_id]
  43. ON [global_table] (
  44. [transaction_id]
  45. )
  46. GO
  47. -- the table to store BranchSession data
  48. CREATE TABLE [branch_table]
  49. (
  50. [branch_id] bigint NOT NULL,
  51. [xid] nvarchar(128) NOT NULL,
  52. [transaction_id] bigint NULL,
  53. [resource_group_id] nvarchar(32) NULL,
  54. [resource_id] nvarchar(256) NULL,
  55. [branch_type] varchar(8) NULL,
  56. [status] tinyint NULL,
  57. [client_id] nvarchar(64) NULL,
  58. [application_data] nvarchar(2000) NULL,
  59. [gmt_create] datetime2 NULL,
  60. [gmt_modified] datetime2 NULL,
  61. PRIMARY KEY CLUSTERED ([branch_id])
  62. WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
  63. )
  64. GO
  65. CREATE NONCLUSTERED INDEX [idx_xid]
  66. ON [branch_table] (
  67. [xid]
  68. )
  69. GO
  70. -- the table to store lock data
  71. CREATE TABLE [lock_table]
  72. (
  73. [row_key] nvarchar(128) NOT NULL,
  74. [xid] nvarchar(128) NULL,
  75. [transaction_id] bigint NULL,
  76. [branch_id] bigint NOT NULL,
  77. [resource_id] nvarchar(256) NULL,
  78. [table_name] nvarchar(32) NULL,
  79. [pk] nvarchar(36) NULL,
  80. [status] tinyint NULL,
  81. [gmt_create] datetime2 NULL,
  82. [gmt_modified] datetime2 NULL,
  83. PRIMARY KEY CLUSTERED ([row_key])
  84. WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
  85. )
  86. GO
  87. CREATE NONCLUSTERED INDEX [idx_status]
  88. ON [lock_table] (
  89. [status]
  90. )
  91. GO
  92. CREATE NONCLUSTERED INDEX [idx_branch_id]
  93. ON [lock_table] (
  94. [branch_id]
  95. )
  96. GO
  97. -- the table to store distributed lock constants
  98. CREATE TABLE [distributed_lock]
  99. (
  100. [lock_key] char(20) not null primary key,
  101. [lock_value] varchar(20) not null,
  102. [expire] bigint
  103. )
  104. GO
  105. INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
  106. INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
  107. INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
  108. INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
  109. INSERT INTO [distributed_lock] (lock_key, lock_value, expire) VALUES ('UndologDelete', ' ', 0);
  110. CREATE TABLE [vgroup_table]
  111. (
  112. [vGroup] nvarchar(255) NOT NULL,
  113. [namespace] nvarchar(255) NOT NULL,
  114. [cluster] nvarchar(255) NOT NULL,
  115. PRIMARY KEY CLUSTERED ([vGroup])
  116. WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
  117. )