Manage keyspaces and tables
Perform limited schema management operations:
-
Get information about one or all keyspaces
-
Edit a keyspace’s configuration
-
Drop a keyspace
-
Truncate a table
-
Drop a table
GET /CLUSTER_ID/keyspaces
Retrieve all configured keyspaces in the cluster.
Path arguments:
* CLUSTER_ID: The ID of a cluster returned from GET /cluster-configs.
Query parameters:
-
ksfields: Optional comma-delimited list of explicit keyspace properties to return.
-
cffields: Optional comma-delimited list of explicit table properties to return.
Returns a dictionary where the key is the keyspace name, and the value is a dictionary of its properties. The list of properties for keyspaces and tables depends on the version of DSE that you’re running.
Example:
curl http://127.0.0.1:8888/Test_Cluster/keyspaces
Output:
{
"Keyspace1": {
"strategy_options": {
"replication_factor": 1
},
"column_families": {
"SuperCounter1": {
"is_in_memory": false,
"create_query": "CREATE TABLE \"Keyspace1\".\"SuperCounter1\" (\key blob, ...)",
"solr_core": false
},
...
}
"durable_writes": true,
"replica_placement_strategy": "org.apache.cassandra.locator.SimpleStrategy",
"is_system": false
},
...
}
GET /CLUSTER_ID/keyspaces/KEYSPACE_NAME
Retrieve information about a specific keyspace in the cluster.
Path arguments:
-
CLUSTER_ID: The ID of a cluster returned from
GET /cluster-configs. -
KEYSPACE_NAME: The value of a
keyspaceproperty in the output ofGET /CLUSTER_ID/keyspaces. -
ksfields: Comma-delimited list of explicit keyspace properties to return.
-
cffields: Comma-delimited list of explicit table properties to return.
Returns the dictionary containing all keyspace properties. The properties returned depend on the version of DSE that you’re running.
Example:
curl http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1
Output:
{
"strategy_options": {
"replication_factor": 1
},
"column_families": {
"SuperCounter1": {
"is_in_memory": false,
"create_query": "CREATE TABLE \"Keyspace1\".\"SuperCounter1\" (\key blob, ...)",
"solr_core": false
},
...
}
"durable_writes": true,
"replica_placement_strategy": "org.apache.cassandra.locator.SimpleStrategy",
"is_system": false
}
PUT /CLUSTER_ID/keyspaces/KEYSPACE_NAME
Update a keyspace.
Path arguments:
-
CLUSTER_ID: The ID of a cluster returned from
GET /cluster-configs. -
KEYSPACE_NAME: The name of the 'keyspace' to update.
Body: A JSON dictionary of all keyspace attributes.
|
The request body is a desired state definition that must include all keyspace attributes. Omitted attributes are reset to default values or cause the operation to fail. |
The JSON body should be similar to the one used when creating a keyspace.
Example:
curl -X PUT http://127.0.0.1:8888/Test_Cluster/keyspaces/Keyspace1 \
-d '{
"strategy_class": "org.apache.cassandra.locator.SimpleStrategy",
"strategy_options": {"replication_factor": "2"},
"durable_writes": true
}'
DELETE /CLUSTER_ID/keyspaces/KEYSPACE_NAME
Drop a keyspace from the cluster.
Path arguments:
-
CLUSTER_ID: The ID of a cluster returned from
GET /cluster-configs. -
KEYSPACE_NAME: The name of the
keyspaceto delete.
Returns 204 response code if the keyspace was deleted successfully.
Example:
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks
DELETE /CLUSTER_ID/data/KEYSPACE_NAME/TABLE_NAME
Truncate a table. Deletes all data from the table but does not delete the table itself.
Path arguments:
-
CLUSTER_ID: The ID of a cluster returned from
GET /cluster-configs. -
KEYSPACE_NAME: The name of the
keyspacecontaining the table. -
TABLE_NAME: The name of the table to truncate.
Returns 204 response code and a null message if the table was truncated successfully.
Example:
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/data/test_ks/users
DELETE /CLUSTER_ID/keyspaces/KEYSPACE_NAME/cf/TABLE_NAME
Drop a table.
Path arguments:
-
CLUSTER_ID: The ID of a cluster returned from
GET /cluster-configs. -
KEYSPACE_NAME: The name of the
keyspacecontaining the table. -
TABLE_NAME: The name of the table to delete.
Returns 204 response code if the table was deleted successfully.
Example:
curl -X DELETE http://127.0.0.1:8888/Test_Cluster/keyspaces/test_ks/cf/users