You can use this on your session:
session.getCluster().getMetadata().getKeyspace(keyspaceName).getTables();
Then you can use exportAsString() to export the CQL command or other methods to explore the table structure.
--
Jacques-Henri Berthemet
--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
java-driver-us...@lists.datastax.com.
One last thing :) beware that exportAsString() has a known bug regarding nested UDTs:
On Tue, Apr 11, 2017 at 9:58 AM Alexandre Dutra <alexand...@datastax.com> wrote:
Just to elaborate on Jacques-Henri's answer, you have two interesting methods in class KeyspaceMetadata:
- asCQLQuery(): returns the CREATE KEYSPACE statement that would re-create the keyspace;
- exportAsString(): returns a human-readable string containing ALL the CQL queries representing this keyspace and its user types, tables, functions, aggregates, as well as secondary indexes and materialized views for every table. This would be the closest equivalent to cqlsh DESCRIBE KEYSPACE command.
Hope that helps,Alexandre Dutra
On Tue, Apr 11, 2017 at 9:22 AM Jacques-Henri Berthemet <jacques-henri.berthemet@genesys.com> wrote:
You can use this on your session:
session.getCluster().getMetadata().getKeyspace(keyspaceName).getTables();
Then you can use exportAsString() to export the CQL command or other methods to explore the table structure.--
Jacques-Henri Berthemet
From: java-driver-user@lists.datastax.com [mailto:java-driver-user@lists.datastax.com] On Behalf Of HM
Sent: mardi 11 avril 2017 04:17
To: DataStax Java Driver for Apache Cassandra User Mailing List <java-driver-user@lists.datastax.com>
Subject: Describe schema using the Java driver
I need to save a keyspace schema.
The command that I would use, using the cqlsh interface would be:
"describe keyspace demo";
How can I do the same thing using the Java driver?
--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.
--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.
--Alexandre DutraDriver & Tools Engineer @ DataStax
--Alexandre DutraDriver & Tools Engineer @ DataStax
--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.