mysql - How to achieve unique auto-incremented id for rows across multiple tables? -


i've got several tables in database, let's they're called table1, table 2, etc. tables have primary key column 'id' auto-increment.

in current configuration happens when inserting table1, generated id 1. afterwards when inserting table2, generated id happens 1 well.

how force absolutely unique ids across tables in database? want when inserting table1, generated id 1, , if afterwards inserting table2, generated id 2?

i used mysql server on machine , did not have problem, when installed mysql on local machine, started occur. guess must kind of setting applied mysql configuration?

thank you

you can use uuid.

insert mytable(id, name) values(select uuid(), 'some data'); 

read more uuid: http://mysqlbackupnet.codeplex.com/wikipage?title=using%20mysql%20with%20guid%20or%20uuid


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -