You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/27 07:58:50 UTC

[GitHub] [shardingsphere] shihuizhen edited a comment on issue #7922: Sharding-proxy How to get the Distributed Primary Key after inserted a new row?

shihuizhen edited a comment on issue #7922:
URL: https://github.com/apache/shardingsphere/issues/7922#issuecomment-717059349


   @Lucas-307  Thanks.
   Is there any way to get id of new row?
   
   When connect MySQL directly, I can get the new row's PRIMARY KEY like this: 
   ```
   CREATE TABLE t_order_item_not_sharding (
   item_id bigint(20) NOT NULL AUTO_INCREMENT,
   order_id bigint(20) unsigned DEFAULT NULL,
   user_id int(11) NOT NULL,
   status varchar(45) DEFAULT NULL,
   creation_date date DEFAULT NULL,
   PRIMARY KEY (item_id)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
   
   ```
   ```root@mysqldb 15:38:  [youhua]> INSERT INTO t_order_item_not_sharding(order_id,user_id,status,creation_date) VALUES (2111,21,' init',' 2017-08-31');
   Query OK, 1 row affected (0.00 sec)
   
   root@mysqldb 15:39:  [youhua]> select @@IDENTITY as insert_id from t_order_item_not_sharding;
   +-----------+
   | insert_id |
   +-----------+
   |         2 |
   |         2 |
   +-----------+
   2 rows in set (0.00 sec)
   
   root@mysqldb 15:39:  [youhua]> select item_id from t_order_item_not_sharding order by item_id desc limit 1;
   +---------+
   | item_id |
   +---------+
   |       2 |
   +---------+
   1 row in set (0.00 sec)```
   
   When use sharding-proxy how to?
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org