GBase 8a数据入库增加时间戳的方法
1、示例表结构
gbase> show create table tt.td;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| td | CREATE TABLE "td" (
"id" int(11) DEFAULT NULL,
"t" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)
2、示例数据
[gbase@vm20 ~]$ cat 2.txt
10000
20000
3、入库语句
gbase> load data infile 'ftp://gbase:gbase@192.168.1.20//home/gbase/2.txt' into table tt.td FIELDS TERMINATED BY '|' table_fields 'id';
Query OK, 2 rows affected (Elapsed: 00:00:00.41)
Task 524299 finished, Loaded 2 records, Skipped 0 records
4、查看入库数据
gbase> select * from tt.td;
+-------+---------------------+
| id | t |
+-------+---------------------+
| 10000 | 2019-10-23 23:58:25 |
| 20000 | 2019-10-23 23:58:25 |
+-------+---------------------+
2 rows in set (Elapsed: 00:00:00.01)
5、注意事项
同一张表不可以对1个以上的timestamp字段设置默认值CURRENT_TIMESTAMP
gbase> alter table td add t1 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ERROR 1702 (HY000): gcluster table error: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause.
热门帖子
- 12025-12-01浏览数:182763
- 22023-05-09浏览数:25057
- 42023-09-25浏览数:18525
- 52020-05-11浏览数:17528