Seata
在数据库中存储数据 创建seata数据库
代码语言:javascript复制drop table if exists global_table;
create table global_table (
xid varchar(128) not null,
transaction_id bigint,
status tinyint not null,
application_id varchar(32),
transaction_service_group varchar(32),
transaction_name varchar(128),
timeout int,
begin_time bigint,
application_data varchar(2000),
gmt_create datetime,
gmt_modified datetime,
primary key (xid),
key idx_gmt_modified_status (gmt_modified, status),
key idx_transaction_id (transaction_id)
);
drop table if exists branch_table;
create table branch_table (
branch_id bigint not null,
xid varchar(128) not null,
transaction_id bigint ,
resource_group_id varchar(32),
resource_id varchar(256) ,
lock_key varchar(128) ,
branch_type varchar(8) ,
status tinyint,
client_id varchar(64),
application_data varchar(2000),
gmt_create datetime,
gmt_modified datetime,
primary key (branch_id),
key idx_xid (xid)
);
drop table if exists lock_table;
create table lock_table (
row_key varchar(128) not null,
xid varchar(96),
transaction_id long ,
branch_id long,
resource_id varchar(256) ,
table_name varchar(32) ,
pk varchar(36) ,
gmt_create datetime ,
gmt_modified datetime,
primary key(row_key)
);
Seata数据库准备
代码语言:javascript复制CREATE DATABASE seata_order;
CREATE DATABASE seata_storage;
CREATE DATABASE seata_account;
在seata_order库下创建t_order表
代码语言:javascript复制create table t_order(
'id' BIGINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
'user_id' BIGINT(11) DEFAULT NULL COMMENT '用户id',
'product_id' BIGINT(11) DEFAULT NULL COMMENT '产品id',
'count' INT(11) DEFAULT NULL COMMENT '数量',
'money' DECIMAL(11,0) DEFAULT NULL COMMENT '金额',
'status' INT(1) DEFAULT NULL COMMENT '订单状态:0:创建中;1:已完结'
) ENGINE=INNODB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
SELECT * FROM t