我如何在 cassandra 数据库中描述 table?

How can i describe table in cassandra database?

$describe = new Cassandra\SimpleStatement(<<<EOD
             describe keyspace.tablename
EOD
    );
    $session->execute($describe);

我使用了上面的代码,但它不起作用。 我如何从 Cassandra table 中获取字段名称及其数据类型?

请参阅 CQL 文档。描述需要 table/schema/keyspace.

describe table keyspace.tablename

它也是一个 cqlsh 命令,而不是一个实际的 cql 命令。要获取此信息,请查询系统表。尝试

select * from system.schema_columns;

- or for more recent versions -

select * from system_schema.columns ;

如果使用 php 驱动程序可能需要查看 http://datastax.github.io/php-driver/features/#schema-metadata

尝试desc table keyspace.tablename;