Showing posts with label drop. Show all posts
Showing posts with label drop. Show all posts

Thursday, 5 March 2020

Cassandra: Drop user defined type

‘DROP TYPE’ keyword is used to drop user defined type.

Syntax:
<drop-type-stmt> ::= DROP TYPE ( IF EXISTS )? <typename>

Example
DROP TYPE address;

cqlsh> CREATE TYPE cassandratutorial.address (
   ... street_name text,
   ...     street_number int,
   ...     city text,
   ...     state text,
   ...     country text,
   ...     zip int
   ... );
cqlsh> 
cqlsh> DESCRIBE TYPE cassandratutorial.address;

CREATE TYPE cassandratutorial.address (
    street_name text,
    street_number int,
    city text,
    state text,
    country text,
    zip int
);
cqlsh> 
cqlsh> DROP TYPE cassandratutorial.address;
cqlsh> 
cqlsh> DESCRIBE cassandratutorial.address;

'address' not found in keyspace 'cassandratutorial'


Previous                                                    Next                                                    Home

Cassandra: Drop Secondary Index

The DROP INDEX statement is used to drop an existing secondary index

Syntax
<drop-index-stmt> ::= DROP INDEX ( IF EXISTS )? ( <keyspace> '.' )? <identifier>

Example
DROP INDEX userIndex;
DROP INDEX userkeyspace.address_index;


Previous                                                    Next                                                    Home

Sunday, 12 January 2020

Cassandra: Drop keyspace if it exists


If you are trying to drop a keyspace, that is not exists, you will get an error like ConfigurationException: Cannot drop non existing keyspace 'cassandratutorial'.

Use the command ‘DROP KEYSPACE IF EXISTS’ to drop the keyspace only if it exist. This command deletes the keyspace, if it exists only, else it ignore.

Syntax
DROP KEYSPACE IF EXISTS keyspace_name

Example
DROP KEYSPACE IF EXISTS cassandratutorial;

Previous                                                    Next                                                    Home

Cassandra: Drop or delete keyspace


You can use 'DROP KEYSPACE' command to drop a keyspace. Once you execute the 'DROP KEYSPACE' command, it removes everything (including tables, functions, data in the keyspace).

Syntax
DROP KEYSPACE [IF EXISTS] keyspace_name

What if you are trying to drop a keyspace, which is not existed anymore?
You will get an error like 'ConfigurationException: Cannot drop non existing keyspace 'cassandratutorial'.

cqlsh> DROP KEYSPACE cassandratutorial;
ConfigurationException: Cannot drop non existing keyspace 'cassandratutorial'.



Previous                                                    Next                                                    Home