What is the SQL command to generate ID by timestamp?

Asked By 0 points N/A Posted on -
qa-featured

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!

SHARE
Best Answer by Michael L London
Answered By 0 points N/A #164905

What is the SQL command to generate ID by timestamp?

qa-featured

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.

 

Best Answer
Best Answer
Answered By 0 points N/A #164907

What is the SQL command to generate ID by timestamp?

qa-featured

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

Login/Register to Answer

Related Questions