timestamp purpose and use if it

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mesut

    timestamp purpose and use if it

    Hi there,

    I'm using a creationDate and ModifiedDate in all my tables with
    Datatype: DateTime.
    In most of my tables I need to do update/delete.

    Do I also need to add a field with data type timestamp in my CRUD
    tables ?
    Why do I need timestamp field ?
    how to use it I mean is it just define the timestamp field in those
    tables? how does that work then?

    thanks mesut
  • Marc Gravell

    #2
    Re: timestamp purpose and use if it

    The timestamp data type has special rules: you can't update it
    yourself, and it always gets updated with any row update. As such, it
    is a very quick way of testing a row for changes, since it is
    impossible to update the row without updating the timestamp. In
    reality, it is just a database-wide counter... every row update
    increments the counter etc.

    You don't *need* a timestamp, but it can be very useful in a lot of
    scenarios. Many ORM tools will recognise timestamps and make
    appropriate concurrency checks (rather than checking every column for
    updates).

    Marc

    Comment

    • mesut

      #3
      Re: timestamp purpose and use if it

      On Sep 19, 3:31 pm, Marc Gravell <marc.grav...@g mail.comwrote:
      The timestamp data type has special rules: you can't update it
      yourself, and it always gets updated with any row update. As such, it
      is a very quick way of testing a row for changes, since it is
      impossible to update the row without updating the timestamp. In
      reality, it is just a database-wide counter... every row update
      increments the counter etc.
      >
      You don't *need* a timestamp, but it can be very useful in a lot of
      scenarios. Many ORM tools will recognise timestamps and make
      appropriate concurrency checks (rather than checking every column for
      updates).
      >
      Marc
      Hi Marc,

      thanks for the info.. So if I understand well it's useful for the
      concurrency checking. Any simple sample you can provide? at least can
      you give the keywords to google?

      thanks again,
      mesut

      Comment

      • Marc Gravell

        #4
        Re: timestamp purpose and use if it

        optimistic concurrency timestamp

        Comment

        Working...