在列级别应用TTL [英] Apply TTL in column level
本文介绍了在列级别应用TTL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
想知道如何在列级应用 TTL
。
Want to know, how to apply TTL
in column level.
以下查询将 TTL
设置为记录级别
below query set the TTL
at record level
INSERT INTO excelsior.clicks (
userid, url, date, name)
VALUES
(
3715e600-2eb0-11e2-81c1-0800200c9a66,
'http://apache.org',
'2013-10-09', 'Mary'
)
USING TTL 86400;
而我的要求是将 TTL
设置为特定列。有什么办法可以做到这一点
whereas my requirement is setting TTL
for a particular column. Is there any way to achieve this
推荐答案
您可以执行 INSERT
部分数据:
cqlsh> create KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
cqlsh> use test;
cqlsh:test> create table test(userid uuid, url text, date text, name text, primary key(userid));
cqlsh:test>
cqlsh:test> insert into test(userid, url, date, name) VALUES
... (
... 3715e600-2eb0-11e2-81c1-0800200c9a66,
... 'http://apache.org',
... '2013-10-09', 'Mary'
... )
... USING TTL 86400;
cqlsh:test>
cqlsh:test> select userid, url, TTL(url), date, TTL(date), name, TTL(name) from test;
userid | url | ttl(url) | date | ttl(date) | name | ttl(name)
--------------------------------------+-------------------+----------+------------+-----------+------+-----------
3715e600-2eb0-11e2-81c1-0800200c9a66 | http://apache.org | 86342 | 2013-10-09 | 86342 | Mary | 86342
(1 rows)
cqlsh:test> insert into test(userid, url ) VALUES (3715e600-2eb0-11e2-81c1-0800200c9a66, 'http://apache.org' ) USING TTL 864000;
cqlsh:test>
cqlsh:test> select userid, url, TTL(url), date, TTL(date), name, TTL(name) from test;
userid | url | ttl(url) | date | ttl(date) | name | ttl(name)
--------------------------------------+-------------------+----------+------------+-----------+------+-----------
3715e600-2eb0-11e2-81c1-0800200c9a66 | http://apache.org | 863992 | 2013-10-09 | 86109 | Mary | 86109
(1 rows)
cqlsh:test>
如果对每列执行插入语句,则可以在每列上分别设置TTL。
If you do an insert statement per column, you can set a TTL on each column individually.
这篇关于在列级别应用TTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文