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

i used above code but it is not working. how can i fetch field name and it's data type from Cassandra table ?

Nirali Kavar
  • 956
  • 2
  • 8
  • 17

2 Answers2

20

Refer to CQL documentation. Describe expects a table/schema/keyspace.

describe table keyspace.tablename

Its also a cqlsh command, not an actual cql command. To get this information query the system tables. try

select * from system.schema_columns;

- or for more recent versions -

select * from system_schema.columns ;

if using php driver may want to check out http://datastax.github.io/php-driver/features/#schema-metadata

Chris Lohfink
  • 16,150
  • 1
  • 29
  • 38
0

Try desc table keyspace.tablename;

xlm
  • 6,854
  • 14
  • 53
  • 55
Vijay
  • 4,694
  • 1
  • 30
  • 38
  • @Vijay: Your query doesn't work with with DevCenter. Can you please share minimum requirements to run this query? – realPK Jan 14 '19 at 22:07
  • 1
    It is not really a good answer - because it explains nothing. But it works. Login (using cqlsh) and from the root you can do `desc table {keyspace}.[table}` Or, login to your keyspace: use {keyspace}, then `desc table {table}` will suffice – Danielson Oct 20 '20 at 13:01