'2017/08/09'에 해당되는 글 1건

  1. 2017.08.09 [cassandra3] select now()


카산드라에서 UUID를 생성하는 방법은 (좀 적은 개수의 로우를 가진) 아무 테이블에서 LIMIT 1로 select now()를 호출한다. 



cqlsh:my_status> SELECT NOW() FROM "user_status_updates" LIMIT 1;


 system.now()

--------------------------------------

 08376da0-7c8e-11e7-95fc-eb95772c8baf


(1 rows)

cqlsh:my_status> SELECT NOW() FROM "user_status_updates" LIMIT 1;


 system.now()

--------------------------------------

 0e2d4ea0-7c8e-11e7-95fc-eb95772c8baf


(1 rows)

cqlsh:my_status> SELECT NOW() FROM "user_status_updates" LIMIT 1;


 system.now()

--------------------------------------

 0eee0690-7c8e-11e7-95fc-eb95772c8baf


(1 rows)

cqlsh:my_status> SELECT NOW() FROM "user_status_updates" LIMIT 1;


 system.now()

--------------------------------------

 0fa63300-7c8e-11e7-95fc-eb95772c8baf


(1 rows)

cqlsh:my_status> SELECT NOW() FROM "user_status_updates" LIMIT 1;


 system.now()

--------------------------------------

 1053b110-7c8e-11e7-95fc-eb95772c8baf





만약 테이블에 now()로 저장된 UUID 필드를 갖고 있다면 다양한 포맷으로 볼 수 있다.

SELECT id, toDate(id), unixtimestampof(id), toTimestamp(id)  FROM "user_status_updates"  limit 1;

 id                                   | system.todate(id) | system.unixtimestampof(id) | system.totimestamp(id)
--------------------------------------+-------------------+----------------------------+---------------------------------
 97719c50-e797-11e3-90ce-5f98e903bf02 |        2014-05-30 |              1401412401813 | 2014-05-30 01:13:21.813000+0000




자세한 내용은 다음을 참조한다.
http://docs.datastax.com/en/cql/3.3/cql/cql_reference/timeuuid_functions_r.html





Posted by '김용환'
,