Apache Cassandra 1.2 Documentation

Querying system tables

The system keyspace includes a number of tables that contain details about your Cassandra database objects and cluster configuration. Cassandra populates these tables and others in the system keyspace:

Table name Column names
schema_keyspaces keyspace_name, durable_writes, strategy_class, strategy_options
local "key", bootstrapped, cluster_name, cql_version, data_center, gossip_generation, partitioner, rack, release_version, ring_id, schema_version, thrift_version, tokens set, truncated at map (1
peers peer, data_center, rack, release_version, ring_id, rpc_address, schema_version, tokens set (2
schema_columns keyspace_name, columnfamily_name, column_name, component_index, index_name, index_options, index_type, validator (3
schema_columnfamilies See (4

(1 Information a node has about itself and a superset of gossip.

(2 Each node records what other nodes tell it about themselves over the gossip.

(3 Used internally with compound primary keys.

(4 You can inspect schema_columnfamilies to get detailed information about specific column families.

Keyspace Information

An alternative to the Thrift API describe_keyspaces function is querying the system tables directly in CQL 3. For example, you can query the defined keyspaces:

SELECT * from system.schema_keyspaces;

The cqlsh output includes information about defined keyspaces. For example:

 keyspace | durable_writes | name    | strategy_class | strategy_options
----------+----------------+---------+----------------+----------------------------
  history |           True | history | SimpleStrategy | {"replication_factor":"1"}
  ks_info |           True | ks_info | SimpleStrategy | {"replication_factor":"1"}

You can also retrieve information about tables by querying system.schema_columnfamilies and about column metadata by querying system.schema_columns.

Cluster information

You can query system tables to get cluster topology information. You can get the IP address of peer nodes, data center and rack names, token values, and other information.

For example, after setting up a 3-node cluster using ccm on the Mac OSX, query the peers and local tables.

USE system;
select * from peers;

Output from querying the peers table looks something like this:

   peer    | data_center | rack  | release_version | ring_id         | rpc_address | schema_version   | tokens
-----------+-------------+-------+-----------------+-----------------+-------------+------------------+-------. . .
 127.0.0.3 | datacenter1 | rack1 | 1.2.0-beta2     | 53d171bc-ff. . .| 127.0.0.3   | 59adb24e-f3 . . .|  {3074. . .
 127.0.0.2 | datacenter1 | rack1 | 1.2.0-beta2     | 3d19cd8f-c9. . .| 127.0.0.2   | 59adb24e-f3 . . .| {-3074. . .}

For more information about system keyspaces, see The data dictionary article.