Skip to content

Instantly share code, notes, and snippets.

@weedge
Created December 17, 2022 18:03
Show Gist options
  • Save weedge/03bb8ddb259a83cc632c6b28e07ec598 to your computer and use it in GitHub Desktop.
Save weedge/03bb8ddb259a83cc632c6b28e07ec598 to your computer and use it in GitHub Desktop.
show engines;
show databases;
show variables like "%partition%" ;
SHOW NODE;
drop database pay;
create database pay PARTITION_MODE=partitioning;
SHOW CREATE DATABASE pay;
use pay;
show db status;
show table status;
drop table `pay`.`user_asset`;
CREATE TABLE `pay`.`user_asset`
(
`userId` bigint unsigned NOT NULL DEFAULT '0',
`assetCn` bigint unsigned NOT NULL DEFAULT '0',
`assetType` tinyint unsigned NOT NULL DEFAULT '0',
`version` bigint unsigned NOT NULL DEFAULT '0',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY `uk_user_assetType` (`userId`,`assetType`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 partition by hash(`userId`) partitions 8;
show create table `pay`.`user_asset`;
show table info from `pay`.`user_asset`;
show topology from `pay`.`user_asset`;
show rule from `pay`.`user_asset`;
select * from `pay`.user_asset;
insert into `pay`.`user_asset` (userId, assetCn, assetType, version, createdAt) values ('100','100','1','1',now());
drop table `pay`.`user_asset_record`;
create table `pay`.`user_asset_record`
(
`userId` bigint unsigned not null default '0',
`opUserType` tinyint unsigned not null default '0',
`bizId` bigint unsigned not null default '0',
`bizType` tinyint unsigned not null default '0',
`objId` varchar(128) not null default '',
`eventId` varchar(128) not null default '',
`eventType` varchar(128) not null default '',
`record` varchar(256) not null default '',
`recordOp` varchar(64) not null default '',
`createdAt` timestamp not null DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp not null default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY `uk_user_opUserType_event` (`userId`,`opUserType`,`eventId`)
)engine=InnoDB default PARTITION BY HASH (`userId`) PARTITIONS 16;
show create table `pay`.`user_asset_record`;
show table info from `pay`.`user_asset_record`;
show topology from `pay`.`user_asset_record`;
show rule from `pay`.`user_asset_record`;
select * from `pay`.`user_asset_record`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment