【问题标题】:run describe schema using datastax cassandra driver 3.0使用 datastax cassandra 驱动程序 3.0 运行描述模式
【发布时间】:2016-12-28 11:30:26
【问题描述】:

当我尝试使用 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”命令?

【问题讨论】:

    标签: cassandra datastax-java-driver


    【解决方案1】:

    DESCRIBE 是一个 cqlsh 扩展。

    你可以这样查询system table

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

    【讨论】:

    • 这个方法只提供键空间信息,我也需要列族的模式。抱歉,如果我的问题不清楚。
    • @VarunGupta 看看链接。还有schema_columnsschema_columnfamilies。稍后我会扩展我的问题。
    • 嘿,更新:应该是keyspace_name = 'keyspacename'
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2016-02-27
      • 2017-01-20
      • 2019-01-31
      • 1970-01-01
      • 2014-05-04
      • 1970-01-01
      • 1970-01-01
      • 2018-02-15
      • 2013-12-23
      相关资源
      最近更新 更多