Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:01:09+00:00 2026-06-07T09:01:09+00:00

Is there a proper native non-workaround auto increment possiblity for ALL tables together in

  • 0

Is there a proper native non-workaround auto increment possiblity for ALL tables together in mySQL ? I mean, not just auto inc per table, i mean ONE number counting up for EACH new row in the database ?

I have seen this on a professional oracle (?) set up. The main advantage is that you have unique id for ALL rows/elements in ALL tables, not just PER TABLE.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:01:10+00:00Added an answer on June 7, 2026 at 9:01 am

    PostgreSQL can be setup like this with a CREATE SEQUENCE seq_name and using nextval(seq_name) on every insert.

    MySQL does not have native support for this, you can simulate the behavior of a PostgreSQL SEQUENCE by creating a table with only one column and an AUTO_INCREMENT on that column.

    You always insert into that table first read the LAST_INSERT_ID of that table to get the id you need to insert into your table. It would be transaction safe so not duplicates would ever be generated.

    Another way to achieve this is to create a table with one column no AUTO_INCREMENT and only one row holding the current max value.

    Every time you need to increment you execute UPDATE seq_table SET seq_column = seq_colum+1; an increment update is in itself atomic but you need to also read the value afterwards which makes two statements and they are not atomic together unless you set a transaction around them and an appropriate isolation level. This approach saves space but also generates locking queries.

    Multiple threads trying to INSERT will have to wait for others to update the seq_table before being able to update it themselves and read the new value.

    Also you’d have to wrap the UPDATE and the SELECT on seq_table in a transaction with an appropriate ISOLATION LEVEL to avoid reading the value that some other thread incremented after you incremented it.

    This means that INSERTS become a transactional issue but normally they aren’t, so i wouldn’t recommend the second approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure if there is a proper term for what I want to
is there any documentation about proper JNA configuration? I do not understand few things:
Is there a proper way to just copy a part of a string after
Is there a proper way, equation or technique in general to say, My web
Is there a proper way yet to unit test views with the aspx view
is there are proper subversion client for ruby, that could be used to manage
Maybe there is a proper term for this, but what if you want to
I wonder, if there is a proper way to remove the default close button
There have been several questions over the past few days about the proper use
I'm new to coffeescript, and while there is extensive information concerning the proper method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.