我有一个带有timestamp类型列的表,当我插入一个值时,scylla用3个零来保存它。
根据锡拉文件(https://docs.scylladb.com/getting-started/types/#timestamps):
时间戳可以输入到cql中,可以使用它们的值作为整数,也可以使用表示iso8601日期的字符串。例如,以下所有值都是2011年3月2日上午04:05:00 gmt的有效时间戳值:
1299038700000
'2011-02-03 04:05+0000'
'2011-02-03 04:05:00+0000'
'2011-02-03 04:05:00.000+0000'
'2011-02-03t04:05+0000'
'2011-02-03t04:05:00+0000'
'2011-02-03t04:05:00.000+0000'
例如,当我创建一个表时:
CREATE TABLE callers (phone text, timestamp timestamp, callID text, PRIMARY KEY(phone, timestamp));
并在其中插入值:
INSERT INTO callers (phone, timestamp, callID) VALUES ('6978311845', 1299038700000, '123');
INSERT INTO callers (phone, timestamp, callID) VALUES ('6978311846', '2011-02-03 04:05+0000', '456');
INSERT INTO callers (phone, timestamp, callID) VALUES ('6978311847', '2011-02-03 04:05:00.000+0000', '789');
这个 SELECT * FROM callers;
将显示所有时间戳,在点后再加3个零:
phone | timestamp | callid
------------+---------------------------------+--------
6978311847 | 2011-02-03 04:05:00.000000+0000 | 789
6978311845 | 2011-03-02 04:05:00.000000+0000 | 123
6978311846 | 2011-02-03 04:05:00.000000+0000 | 456
例如,当我尝试删除一行时:
DELETE FROM callers WHERE phone = '6978311845' AND timestamp = '2011-03-02 04:05:00.000000+0000';
出现错误:
InvalidRequest: Error from server: code=2200 [Invalid query] message="marshaling error: unable to parse date '2011-03-02 04:05:00.000000+0000': marshaling error: Milliseconds length exceeds expected (6)"
如何存储时间戳而不出现此错误?
1条答案
按热度按时间niknxzdl1#
你有人力资源:min:sec.millisec ->毫秒可以达到999/1000,所以本质上这就是错误所说的。
第三个
INSERT
你所做的陈述在语法上是正确的。这个
DELETE
语句的格式应与INSERT
:AND timestamp = '2011-03-02 04:05:00.00+0000'
AND timestamp = '2011-03-02 04:05:00.000+0000'
AND timestamp = '2011-03-02 04:05:00+0000'AND timestamp = '2011-03-02 04:05:00'
额外的000
出现在表中的只是显示问题。