gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 06:37:32 27 4
gpt4 key购买 nike

假设我使用 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 表的信息。

最佳答案

您应该尝试使用 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

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

关于cassandra - 有没有办法发现 Cassandra CQL 表结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18106043/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com