前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >分布式事务

分布式事务

作者头像
用户8447427
发布2023-10-18 15:09:14
发布2023-10-18 15:09:14
16600
代码可运行
举报
文章被收录于专栏:userlyz学习记录userlyz学习记录
运行总次数:0
代码可运行

Seata

在数据库中存储数据 创建seata数据库

代码语言:javascript
代码运行次数:0
复制
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
代码运行次数:0
复制
CREATE DATABASE seata_order;
CREATE DATABASE seata_storage;
CREATE DATABASE seata_account;

在seata_order库下创建t_order表

代码语言:javascript
代码运行次数:0
复制
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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-08-03,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Seata
    • Seata数据库准备
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档