isa*_*zan 14 sql amazon-redshift
有没有办法创建一个时间戳列默认为现在的表?
以下任何一项在创建时都会成功,但在插入时会失败.
CREATE TABLE MyTable
(
device_id VARCHAR(64) NOT NULL encode lzo,
app_id VARCHAR(150) NOT NULL distkey encode lzo,
retrieval_date TIMESTAMP without time zone default (now() at time zone 'utc') encode lzo
)
diststyle key
compound sortkey(app_id,device_id);
Run Code Online (Sandbox Code Playgroud)
然后插入:
insert into MyTable (device_id,app_id) values('a','b');
INFO: Function "timezone(text,timestamp with time zone)" not supported.
INFO: Function "now()" not supported.
ERROR: Specified types or functions (one per INFO message) not supported on Redshift tables.
Run Code Online (Sandbox Code Playgroud)
我尝试了以下其他口味,但都失败了.
a)现在用单引号'now'试过,创建成功但失败了另一个错误
b)尝试没有时区,创建成功,插入失败.
Mas*_*aki 27
您可以使用SYSDATE
或GETDATE()
设置当前时间戳值.这是一个例子.
dev=> create table my_table (id int, created_at datetime default sysdate);
CREATE TABLE
dev=> insert into my_table (id) values (1);
INSERT 0 1
dev=> select * from my_table;
id | created_at
----+---------------------------
1 | 2016-01-04 19:07:14.18745
(1 row)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17152 次 |
最近记录: |