企业实战_16_MyCat全局自增ID
接上一篇:企業實戰_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.sql4. 登錄驗證
# 登錄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數據庫所在數據節點名稱
2.5. 設置自增屬性
最后在mycat數據庫中,給mycat_sequence 插入一條數據,設置自增屬性
insert into mycat_sequence values (‘order_key’,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> 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"屬性
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 start3.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
總結
以上是生活随笔為你收集整理的企业实战_16_MyCat全局自增ID的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dubbo之.xml配置文件报错
- 下一篇: 基于JVisualVM的可视化监控