运行 使用 datastax cassandra 驱动程序 3.0 描述模式

run describe schema using datastax cassandra driver 3.0

当我尝试使用 datastax 驱动程序 3.0 运行 "describe keyspace keyspacename" 命令时,它给我一个错误

Exception in thread "main" com.datastax.driver.core.exceptions.SyntaxError: line 1:0 no viable alternative at input 'DESCRIBE' ([DESCRIBE]...)

如何运行"describe keyspace keyspacename"命令?

DESCRIBE 是一个 cqlsh 扩展。

您可以这样查询system table

SELECT * from system.schema_keyspaces 
 WHERE keyspace_name = 'keyspacename';

Datastax 的 Java 驱动程序有一个 class KeyspaceMetadata,它公开了方法 exportAsString。所以我使用该方法使用该方法将整个键空间模式作为字符串获取。