How can I update a column with type TIMESTAMP in Oracle via sql query?

I have a column:

"LASTTOUCH" TIMESTAMP(9) NOT NULL ENABLE 

and I have to set the current date in this column.

But I have no idea how I can do this.

could you help me?

+8
sql database oracle timestamp
source share
3 answers

Insert:

 insert into tablename (LASTTOUCH) values (CURRENT_TIMESTAMP); 

Update:

 update tablename set LASTTOUCH=CURRENT_TIMESTAMP; 
+13
source share

If you want the current time (including the accuracy of the timestamp), you can use either systimestamp or current_timestamp

 SQL> select systimestamp from dual; SYSTIMESTAMP --------------------------------------------------------------------------- 04-OCT-12 11.39.37.670428 AM -04:00 SQL> select CURRENT_TIMESTAMP from dual; CURRENT_TIMESTAMP --------------------------------------------------------------------------- 04-OCT-12 11.39.51.021937 AM -04:00 update table_name set column_name = SYSTIMESTAMP where id = 100; 

If you just set the value to sysdate, part of the second part of the timestamp is reset to zero because the date is implicitly converted to a timestamp.

 SQL> create table t1( 2 time1 timestamp 3 ); Table created. SQL> insert into t1 values (sysdate); 1 row created. SQL> commit; SQL> select to_char(time1,'MM/DD/YYYY HH24:MI:SS.FF6') result from t1; RESULT ----------------------------- 10/04/2012 11:43:07.000000 
+6
source share
 INSERT INTO tableName VALUES (SYSDATE); 

OR

 UPDATE tableName SET COLUMN = SYSDATE; 
0
source share

All Articles