有没有办法发现Cassandra CQL表结构?

时间:2013-08-07 14:25:39

标签: cassandra cql

假设我使用CQL来定义此表。

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

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

我正在考虑等同于MySQL DESCRIBE {tablename}命令。

[编辑]

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

2 个答案:

答案 0 :(得分:27)

您应该尝试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!) download
  • 将python添加到您的路径(作为新的环境变量)
  • 导航到运行设置 在cmd提示符中C:\dir\to\cassandra\pylib并执行以下操作 行:

    python setup.py install
    

GZ。现在你在windows上有cqlsh。

答案 1 :(得分:7)

也可以使用DevCenter和OpsCenter完成。

DevCenter:在Schema中找到表格 - &gt;右键单击 - &gt;克隆表。您可以在窗口按钮找到CQL预览。

OpsCenter:群集 - &gt;数据 - &gt;表