No announcement yet.

Name sequence

  • Filter
  • Time
  • Show
Clear All
new posts

  • Name sequence

    Who tells me the exact meaning of the "name sequence" in "autoincremant" field ?


  • #2
    You basically need to know about autoincrement and sequences (sequence tables). If you do not use sequence tables in your DB then "sequence name" has no meaning. However, for education.... I "borrowed" this and modified its context from the o'reilly website:

    The best kind of primary key is one that has absolutely no meaning in the database except to act as a primary key. The best way to achieve this is to make a numeric primary key that increments every time you insert a new row. Looking at a "cities" table, the first city you insert would have an id of 1, the second 2, the third 3, and so on.

    In order to successfully manage this sequencing of a primary key, you need some way to guarantee that a number can be read and incremented by one and only one client at a time. Under transactional databases, you could create a table called sequence that has a number representing the next id. When you need to insert a new row, you would read that table and insert a new number one more than the one you read. You must be assured that no one else will read from that table before you insert a new value, however, in order for that scheme to work. Otherwise, two clients could read the same value and attempt to use it as a primary key value in the same table.


    • #3
      interesting adz, didn't read that before, i guess this is beneficial if you have large number of users using the same table in the same time right!? could you make a project/sql dump example if you have time so everyone will benefit from this important point, thankfully.


      • #4

        I've not used them myself as I don't have a high level of multiple client access, I just "knew" a bit about them - however, this screenshot illustrates the "principal":


        Now, this is NOT showing using a sequence table, but shows "pseudo" sequence table behaviour to illustrate the theory. You'll need to research it yourself I'm afraid (lots out there) in terms of actually using sequence tables.

        The point being that SC allows you to point to a sequence table you have setup for the next number on AI fields. I presume that SC uses the values as per the screenshot if you do NOT provide your own actual sequence tables. Also, if sequence table name is specified in SC, not sure if SC updates the sequence table for you, or you have to manage it yourself (as I said - not used them - I just understand the principal)


        • #5
          interesting, thanks dear, a coming project may involve high number of users with AI and may need this, will let you know if forced t use and what is the outcome