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

Vin*_*nie 14 cql cassandra

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

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

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

我在考虑与MySQL DESCRIBE {tablename}命令相同的东西.

[编辑]

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

Lyu*_*rov 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'};
Run Code Online (Sandbox Code Playgroud)

编辑
虽然我联系的博客很棒,但是很棒.在Windows中运行cqlsh:

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

    python setup.py install
    
    Run Code Online (Sandbox Code Playgroud)

GZ.现在你在windows上有cqlsh.


Kai*_*ang 7

它也可以使用DevCenter和OpsCenter完成.

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

OpsCenter:群集 - >数据 - >表