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:41:25 UTC

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

Lucas-307 commented on issue #7922:
URL: https://github.com/apache/shardingsphere/issues/7922#issuecomment-717051656


   @shihuizhen HI, I don't think `select @@IDENTITY as insert_id from t_order_item;` is correct sql. Maybe you mean `select @@IDENTITY as insert_id;`
   
   Foucs on this Question.
   
   As we know, there are several actual datasources.
   
   `INSERT INTO t_order_item(order_id,user_id,status,creation_date) VALUES (2111,21,' init',' 2017-08-31')` will insert into a specific datasource.
   
   but `select @@IDENTITY` or `SELECT LAST_INSERT_ID()` will execute in a random datasource.(do not have sharding keys)
   
   So, we can't make sure `select @@IDENTITY` or `SELECT LAST_INSERT_ID()` is what you want.


----------------------------------------------------------------
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