Asked By
hirt faust
0 points
N/A
Posted on - 02/18/2013
Dear Database Administrators,
I know you could help me regarding my SQL problem.
I am currently doing a site using VB.net and SQL server.
I just wanted to know the SQL command to generate ID by timestamp.
Thank you so much!
What is the SQL command to generate ID by timestamp?
Hi Hirt,
You can use the following query  while creating a table to set the id as time stamp.
CREATE TABLE example_timestamp (Â Â Â Â Â Â Â Â
        data VARCHAR(100),
        id TIMESTAMP(8)
      );
Whenever you insert or update the table the id field value will automatically pick the current timestamp.
You  can select the current timestamp from system using following query.
SELECT SYSTIMESTAMP AS TSTAMP FROM DUAL;
You can Populate a Timestamp Field With Current Timestamp using following query.
INSERT INTO TABLE_NAME(TSTAMP) VALUES ((SELECT SYSTIMESTAMP FROM DUAL));
Hope this will work for you.
Â
What is the SQL command to generate ID by timestamp?
Hello Hirt faust,
If this is your first time, then you should look at the official 'alter table' syntax, but it looks like this is not supported: IBM DB2 9.5 Information Center for Linux, UNIX, and Windows.
You may be not able to figure it out if this is your first time.
So you can check it out at the site may more helpful for you–
There you will get some test that you should try your own.
Thanks for asking here at techyv.com. Feel free to post your queries here at techyv.com
Best regards,
Michael L London