Loading ...
Sorry, an error occurred while loading the content.

shouldn't all datatables be timestamped?

Expand Messages
  • Terrence Brannon
    During development, I often want to quickly see if a table just successfully inserted a new record. In MySQL, a field can be used this way. Are there any
    Message 1 of 5 , Jan 10, 2005
    • 0 Attachment
      During development, I often want to quickly see if a table just
      successfully inserted a new record.

      In MySQL, a field can be used this way. Are there any drawbacks to
      using such a field? Of course inserts will be a bit slower. But it is
      certainly useful in a dev environment.
    • shanker nagarajan
      The document says it works for 4.1.x or above. Create a table with timestamp column with default as current_timestamp so you can avoid the INSERT load. CREATE
      Message 2 of 5 , Jan 10, 2005
      • 0 Attachment
        The document says it works for 4.1.x or above.
        Create a table with timestamp column with default as
        current_timestamp so you can avoid the INSERT load.
        CREATE TABLE tmp (

        ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        ON UPDATE CURRENT_TIMESTAMP);



        -Shanker

        --- Terrence Brannon <terry@...> wrote:

        > During development, I often want to quickly see if a
        > table just
        > successfully inserted a new record.
        >
        > In MySQL, a field can be used this way. Are there
        > any drawbacks to
        > using such a field? Of course inserts will be a bit
        > slower. But it is
        > certainly useful in a dev environment.
        >
        >


        =====
        Shankar Nagarajan,
        Flat# S10, S11, 2nd Floor,
        Etinasarva-2 Apts, Begur Road,
        Bommanahalli, BANGALORE, KA, IN.
        Cell: 91-98454-72242




        __________________________________
        Do you Yahoo!?
        Yahoo! Mail - 250MB free storage. Do more. Manage less.
        http://info.mail.yahoo.com/mail_250
      • chromatic
        ... I prefer to count the number of rows before and after an operation instead of relying on the side effect of a change to hint that the right thing happened.
        Message 3 of 5 , Feb 10 4:44 PM
        • 0 Attachment
          On Tue, 2005-01-11 at 01:23 +0000, Terrence Brannon wrote:

          > During development, I often want to quickly see if a table just
          > successfully inserted a new record.
          >
          > In MySQL, a field can be used this way. Are there any drawbacks to
          > using such a field? Of course inserts will be a bit slower. But it is
          > certainly useful in a dev environment.

          I prefer to count the number of rows before and after an operation
          instead of relying on the side effect of a change to hint that the right
          thing happened.

          -- c
        • Adrian Howard
          ... Ditto. I also have a /very/ strong aversion to having my development environment and live environments differ. I want to have the same tests run in the
          Message 4 of 5 , Feb 11 7:01 AM
          • 0 Attachment
            On 11 Feb 2005, at 00:44, chromatic wrote:
            > On Tue, 2005-01-11 at 01:23 +0000, Terrence Brannon wrote:
            >
            >> During development, I often want to quickly see if a table just
            >> successfully inserted a new record.
            >>
            >> In MySQL, a field can be used this way. Are there any drawbacks to
            >> using such a field? Of course inserts will be a bit slower. But it is
            >> certainly useful in a dev environment.
            >
            > I prefer to count the number of rows before and after an operation
            > instead of relying on the side effect of a change to hint that the
            > right
            > thing happened.

            Ditto.

            I also have a /very/ strong aversion to having my development
            environment and live environments differ. I want to have the same tests
            run in the same way everywhere. Having things like database schema
            varying between dev/live scares me :-)

            Adrian
          • Ed Grimm
            ... Disclaimer: I code for an LDAP database, not a MySQL database. However, I think many principles still hold... Somehow, the natural thing to me would be to
            Message 5 of 5 , Feb 13 1:45 AM
            • 0 Attachment
              On Thu, 10 Feb 2005, chromatic wrote:
              > On Tue, 2005-01-11 at 01:23 +0000, Terrence Brannon wrote:
              >
              >> During development, I often want to quickly see if a table just
              >> successfully inserted a new record.
              >>
              >> In MySQL, a field can be used this way. Are there any drawbacks to
              >> using such a field? Of course inserts will be a bit slower. But it is
              >> certainly useful in a dev environment.
              >
              > I prefer to count the number of rows before and after an operation
              > instead of relying on the side effect of a change to hint that the right
              > thing happened.

              Disclaimer: I code for an LDAP database, not a MySQL database. However,
              I think many principles still hold...

              Somehow, the natural thing to me would be to check for the data you're
              trying to add before you add it, verifying that it's not there, and then
              check for it after you add it, and verify that it's there. During a
              unit test of the database itself, I'd also check to make certain that
              the row counts have changed, and possibly, if I was being pedantic,
              checking the rest of the entries to make certain they've not vanished.

              But, if I'm not testing the database itself, and merely testing my code
              to work with the database, the fact that the new data is now in the
              database, and it wasn't before, is certainly sufficient for me to feel
              the data was, in fact, added.

              So far, this has only failed one time, when a coworker decided to have a
              process read the audit log, look for my additions, and delete them.
              (Given that my investigation technique was to check the logs, this
              didn't have quite the result he was looking for.)

              Ed
            Your message has been successfully submitted and would be delivered to recipients shortly.