14

假设我使用 CQL 来定义这个表。

CREATE TABLE songs (
    id uuid PRIMARY KEY, 
    title text,
    album text, 
    artist text, 
    tags set<text>, 
    data blob);

其他开发人员(或几周后的我自己)如何(重新)发现此表的布局?

我正在考虑等效于 MySQLDESCRIBE {tablename}命令。

[编辑]

我看到 Cassandra 的命令行界面 (CLI) 中有一个DESCRIBE方法,但在使用它时,它声明它的结果中不包含有关 CQL 表的信息。

4

2 回答 2

28

你应该试试这个cqlsh工具,它会告诉你你想要什么:

lyubent@vm: ~$ ./cqlsh 
cqlsh> use system;
cqlsh> describe columnfamily local;

CREATE TABLE local (
  key text PRIMARY KEY,
  bootstrapped text,
  cluster_name text,
  cql_version text,
  data_center text,
  gossip_generation int,
  host_id uuid,
  partitioner text,
  rack text,
  release_version text,
  schema_version uuid,
  thrift_version text,
  tokens set<text>,
  truncated_at map<uuid, blob>
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='information about the local node' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=0 AND
  read_repair_chance=0.000000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};

编辑
虽然当时很棒,但我链接的博客很好。在 Windows 中运行 cqlsh:

  • 首先安装python 2.7.x(不是python 3!) 下载
  • 将 python 添加到您的路径(作为新的环境变量)
  • 通过导航到 C:\dir\to\cassandra\pylibcmd 提示符并执行以下行来运行设置:

    python setup.py install
    

广州。现在你在 Windows 上有了 cqlsh。

于 2013-08-07T14:56:26.780 回答
10

也可以使用 DevCenter 和 OpsCenter 完成。

DevCenter:在Schema中找到表->右键->克隆表。您可以在窗口的按钮上找到 CQL 预览。

OpsCenter:集群 -> 数据 -> 表

于 2015-10-15T20:45:31.050 回答