Create a table in which timestamps can be stored. : TimeStamp « Data Type « SQL / MySQL






Create a table in which timestamps can be stored.

      
mysql>
mysql> CREATE TABLE TSTAMP (COL1 TIMESTAMP);
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> SET @TIME = TIMESTAMP('1980-12-08 23:59:59.59');
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO TSTAMP VALUES (@TIME + INTERVAL 3 MICROSECOND);
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> SELECT COL1, COL1 + INTERVAL 3 MICROSECOND FROM TSTAMP;
+---------------------+-------------------------------+
| COL1                | COL1 + INTERVAL 3 MICROSECOND |
+---------------------+-------------------------------+
| 1980-12-08 23:59:59 | 1980-12-08 23:59:59.000003    |
+---------------------+-------------------------------+
1 row in set (0.00 sec)

mysql>
mysql> drop table tstamp;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
    
    
  








Related examples in the same category

1.TIMESTAMP as column type
2.timestamp type column default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
3.Table definition includes a YEAR column and a TIMESTAMP
4.Order by timestamp value
5.dates and times in SQL commands must be given as character strings,
6.Recording a Row's Last Modification Time
7.Recording a Row's Creation Time
8.Performing Calculations with TIMESTAMP Values
9.Updates to tsdemo2 records that don't actually modify a column cause no change to TIMESTAMP values
10.The difference between the creation and modification times
11.Issuing an UPDATE statement that doesn't actually change the values in the val column doesn't update the TIMES
12.microseconds component is removed.