接上一篇:企业实战_15_MySql主从复制到MyCat总结
https://gblfy.blog.csdn.net/article/details/118657995
文章目录
- 一、准备工作
- 1. Mycat全局自增实现思路
- 2. 创建mycat数据库
- 3. 导入初始化脚本
- 4. 登录验证
- 二、配置文件修改
- 2.1. server.xml配置
- 2.2. 添加数据节点
- 2.3. 验证im_mycat权限
- 2.4. 配置数据节点和逻辑表明
- 2.5. 设置自增属性
- 2.6. 开启自增属性
- 2.7. 赋予权限
- 三、测试验证
- 3.1. 重启mycat
- 3.2. 数据清理
- 3.3. 批量插入数据
- 3.4. 查看数据
- 3.5. 得出结论
- 3.6. 执行记录
一、准备工作
1. Mycat全局自增实现思路
- 在任意节点创建mycat数据库
- 将/app/mycat/conf/dbseq.sql文件中的数据导入到mycat数据库中
- 修改schema.xml文件添加主机节点和数据节点,如果主机节点已经存在,可以不添加
- 修改server.xml设置增增ID生成类型为数据库形式
- 修改 sequence_db_conf.properties文件,设置那些逻辑表需要自增ID和数据节点的名称
- 给mycat数据库中的MYCAT_SEQUENCE 表插入一条数据,设置定增属性
- 修改schema.xml文件,设置给哪个逻辑表自用自增ID
- 赋予mycat用户操作函数的权限
- 重新启动mycat
- 数据清理
- 批量插入数据,查看order_id 是否重复
2. 创建mycat数据库
在任意节点,创建mycat数据库,这里演示在node1节点创建mycat数据库
# 登录node1节点的mysql
mysql -uroot -p123456# 查看数据库列表
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| imooc_db |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.01 sec)# 创建数据库
create database mycat;mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| imooc_db |
| mycat |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 rows in set (0.00 sec)
注:其他节点创建mycat数据库一样
3. 导入初始化脚本
将dbseq.sql导入MyCat数据库中
# 进入mycat的conf目录
cd /app/mycat/conf# 初始化表结构脚本
mysql -uroot -p mycat < dbseq.sql
4. 登录验证
# 登录mycat数据库
mysql -uroot -p123456# 使用mycat数据库
use mycat;# 查看初始化脚本后的数据库有哪些对象
show tables;# 查看MYCAT_SEQUENCE表中数据
select * from MYCAT_SEQUENCE;可以看出设置了全局id 1 自增1
mysql> use mycat;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> show tables;
+-----------------+
| Tables_in_mycat |
+-----------------+
| MYCAT_SEQUENCE |
+-----------------+
1 row in set (0.00 sec)mysql> select * from MYCAT_SEQUENCE;
+--------+---------------+-----------+
| name | current_value | increment |
+--------+---------------+-----------+
| GLOBAL | 1 | 1 |
+--------+---------------+-----------+
1 row in set (0.00 sec)
二、配置文件修改
2.1. server.xml配置
cd /app/mycat/conf/
vim server.xml
<!--
0-以本地文件生成序列号
1-以数据库形式
2-时间戳序列
3-以zookeeper形式生成自增序列
-->
# 将此属性修改为1 ,1代表从数据库中读取
# 告诉mycat我是石勇数据库读取的方式生成全局自增id
<property name="sequnceHandlerType">1</property>
2.2. 添加数据节点
在schema.xml文件中,添加数据主机节点
<dataHost name="mysql92101" maxCon="1000" minCon="10" balance="3" writeType="0" dbType="mysql" dbDriver="native" switchType="1"><heartbeat>select user()</heartbeat><writeHost host="192.168.92.101" url="192.168.92.101:3306" user="im_mycat" password="123456"></writeHost></dataHost>
添加数据节点
<dataNode name="mycat" dataHost="mysql92101" database="mycat" />
注:如果mycat数据库和分片的某一个数据库节点在一个mysql中,添加dohost节点这一步可以省略
2.3. 验证im_mycat权限
# 登录mysql
mysql -uroot -p123456# 使用mysql数据库
mysql> use mysql;
Database changed
mysql> select user,host from user;
+---------------+--------------+
| user | host |
+---------------+--------------+
| root | % |
| im_mycat | 192.168.92.% |
| im_repl | 192.168.92.% |
| mysql.session | localhost |
| mysql.sys | localhost |
+---------------+--------------+
5 rows in set (0.00 sec)# 查看im_mycat用户权限
mysql> show grants for im_mycat@'192.168.92.%';
+-----------------------------------------------------------------------------------+
| Grants for im_mycat@192.168.92.% |
+-----------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON *.* TO 'im_mycat'@'192.168.92.%' |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
2.4. 配置数据节点和逻辑表明
sequence_db_conf.properties
- 数据节点
- 自增表和mycay数据库所在数据节点名称
# 指定表、函数所在的数据节点
vim sequence_db_conf.propertiesGLOBAL=mycat
# ORDER_MASTER表所在的数据节点
ORDER_MASTER=mycat
2.5. 设置自增属性
最后在mycat数据库中,给mycat_sequence 插入一条数据,设置自增属性
insert into mycat_sequence values (‘order_key’,1,1);
#再次查看
# 登录mysql
mysql -uroot -p123456# 使用mycat数据库
use mycat;# 查询MYCAT_SEQUENCE
select * from MYCAT_SEQUENCE;# 给MYCAT_SEQUENCE 插入一条数据,设置定增属性
insert into MYCAT_SEQUENCE VALUES ('ORDER_MASTER',1,1);# 再次查看
select * from MYCAT_SEQUENCE;
执行记录:
mysql> use mycat
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> select * from MYCAT_SEQUENCE;
+--------+---------------+-----------+
| name | current_value | increment |
+--------+---------------+-----------+
| GLOBAL | 1 | 1 |
+--------+---------------+-----------+
1 row in set (0.00 sec)mysql> insert into MYCAT_SEQUENCE VALUES ('ORDER_MASTER',1,1);
Query OK, 1 row affected (0.01 sec)mysql> select * from MYCAT_SEQUENCE;
+--------------+---------------+-----------+
| name | current_value | increment |
+--------------+---------------+-----------+
| GLOBAL | 1 | 1 |
| ORDER_MASTER | 1 | 1 |
+--------------+---------------+-----------+
2 rows in set (0.00 sec)mysql>
2.6. 开启自增属性
在ORDER_MASTER 的逻辑表中添加autoIncrement="true"
属性
在逻辑表(ORDER_MASTER )中,添加autoIncrement="true"属性
cd /app/mycat/confvim schema.xml
<table name="order_master" primaryKey="order_id" dataNode="ordb01,ordb02,ordb03,ordb04" rule="order_master" autoIncrement="true"/>
2.7. 赋予权限
赋予权限im_mycat
用户执行函数的权限
mysql -uroot -p123456
use mysql;
show grants for im_mycat@'192.168.92.%';# 赋予权限`im_mycat`用户执行函数的权限
grant execute on *.* to 'im_mycat'@'192.168.92.%';show grants for im_mycat@'192.168.92.%';
执行日志
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> show grants for im_mycat@'192.168.92.%';
+-----------------------------------------------------------------------------------+
| Grants for im_mycat@192.168.92.% |
+-----------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON *.* TO 'im_mycat'@'192.168.92.%' |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> grant execute on *.* to 'im_mycat'@'192.168.92.%';
Query OK, 0 rows affected (0.01 sec)mysql> show grants for im_mycat@'192.168.92.%';
+-----------------------------------------------------------------------------------+
| Grants for im_mycat@192.168.92.% |
+-----------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON *.* TO 'im_mycat'@'192.168.92.%' |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)mysql>
三、测试验证
3.1. 重启mycat
重新启动mycat
mycat stopmycat start
3.2. 数据清理
mysql -uapp_imooc -p123456 -h192.168.92.101 -P8066
use imooc_db;
delete from order_master;
3.3. 批量插入数据
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 1, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (2, 2, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 3, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 4, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 5, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 6, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 7, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 8, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 9, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES ( 1,10, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
3.4. 查看数据
mysql> select customer_id,order_sn,order_id from order_master order by order_id;
+-------------+----------+----------+
| customer_id | order_sn | order_id |
+-------------+----------+----------+
| 1 | 1 | 2 |
| 2 | 2 | 3 |
| 3 | 1 | 4 |
| 4 | 1 | 5 |
| 5 | 1 | 6 |
| 6 | 1 | 7 |
| 7 | 1 | 8 |
| 8 | 1 | 9 |
| 9 | 1 | 10 |
| 10 | 1 | 11 |
+-------------+----------+----------+
10 rows in set (0.03 sec)
3.5. 得出结论
经过配置之后,订单order_id就不会重复了
下一篇:企业实战_12_Mycat水平扩展_跨分片查询_ER分片
https://blog.csdn.net/weixin_40816738/article/details/100066013
3.6. 执行记录
[root@node1 ~]# mysql -uapp_imooc -p123456 -h192.168.92.101 -P8066
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.29-mycat-1.6.5-release-20180122220033 MyCat Server (OpenCloundDB)Copyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;
+----------+
| DATABASE |
+----------+
| imooc_db |
+----------+
1 row in set (0.00 sec)mysql> use imooc_db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> show tables;
+-----------------------+
| Tables in imooc_db |
+-----------------------+
| customer_balance_log |
| customer_inf |
| customer_level_inf |
| customer_login |
| customer_login_log |
| customer_point_log |
| order_cart |
| order_customer_addr |
| order_detail |
| order_master |
| product_brand_info |
| product_category |
| product_comment |
| product_info |
| product_pic_info |
| product_supplier_info |
| region_info |
| shipping_info |
| warehouse_info |
| warehouse_proudct |
+-----------------------+
20 rows in set (0.00 sec)mysql> delete from order_master;
Query OK, 10 rows affected (0.02 sec)mysql> select * from order_master;
Empty set (0.01 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
ustomer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shippme,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) VALUES (1, 3, '雨昕', 1, 1, 1, '北京',NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) 京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) 京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) 京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) 京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_mo)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
ey,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_poALUES (1, 8, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) 京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time) 京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
Query OK, 1 row affected (0.12 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.12 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.12 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.12 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_ 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> select customer_id,order_sn,order_id from order_master order by order_id;
+-------------+----------+----------+
| customer_id | order_sn | order_id |
+-------------+----------+----------+
| 1 | 1 | 2 |
| 2 | 2 | 3 |
| 3 | 1 | 4 |
| 4 | 1 | 5 |
| 5 | 1 | 6 |
| 6 | 1 | 7 |
| 7 | 1 | 8 |
| 8 | 1 | 9 |
| 9 | 1 | 10 |
| 10 | 1 | 11 |
+-------------+----------+----------+
10 rows in set (0.03 sec)mysql>
下一篇:企业实战_17_MyCat水平扩展_跨分片查询_ER分片
https://gblfy.blog.csdn.net/article/details/100066013