github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/func_datetime_utc_timestamp.test (about)

     1  create table t1 (ts timestamp);
     2  set time_zone='+00:00';
     3  select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());
     4  insert into t1 (ts) values ('2003-03-30 02:30:00');
     5  set time_zone='+10:30';
     6  select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());
     7  insert into t1 (ts) values ('2003-03-30 02:30:00');
     8  set time_zone='-10:00';
     9  #select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());
    10  insert into t1 (ts) values ('2003-03-30 02:30:00');
    11  select * from t1;
    12  drop table t1;
    13  
    14  
    15  #SELECT,  算术运算,嵌套
    16  
    17  select utc_timestamp()-utc_timestamp(),weekday(utc_timestamp())-weekday(utc_timestamp()),unix_timestamp()-unix_timestamp(utc_timestamp());
    18  
    19  #0.5 not supported
    20  #select utc_timestamp()-curdate()*1000000-curtime();
    21  
    22  #INSERT
    23  #CREATE TABLE t1 (a TIMESTAMP);
    24  #INSERT INTO t1 VALUES (utc_timestamp()), (utc_timestamp());
    25  #SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a);
    26  #DROP TABLE t1;
    27  
    28  
    29  CREATE TABLE t1 (a TIMESTAMP);
    30  INSERT INTO t1 select (utc_timestamp());
    31  INSERT INTO t1 select (utc_timestamp());
    32  SELECT 1 FROM t1 ORDER BY 1;
    33  DROP TABLE t1;
    34  
    35  
    36  #INSERT
    37  DROP TABLE if exists t1;
    38  #create table t1 (a int primary key, b int, c int, d timestamp default current_timestamp);
    39  create table t1 (a int primary key, b int, c int, d timestamp);
    40  insert into t1 select 1,1,1,utc_timestamp();
    41  insert into t1 select 2,0,0,null;
    42  select a,b,c,year(d) from t1;
    43  DROP TABLE t1;
    44  
    45  
    46  #比较运算,数据类型
    47  
    48  CREATE TABLE t1 (a TIMESTAMP);
    49  INSERT INTO t1 select (utc_timestamp());
    50  INSERT INTO t1 select (utc_timestamp());
    51  INSERT INTO t1 select (utc_timestamp());
    52  SELECT year(a) FROM t1 WHERE a > '2008-01-01';
    53  DROP TABLE t1;
    54  
    55  
    56  #算术运算,CREATE SELECT
    57  #0.5 not supported
    58  #create table t1 select utc_timestamp() - utc_timestamp(), curtime() - curtime(), sec_to_time(1) + 0, from_unixtime(1) + 0;
    59  #select * from t1;
    60  #drop table t1;