You can alter user define type using ‘ALTER TYPE’ statement.
Syntax
<alter-type-stmt> ::= ALTER TYPE <typename> <instruction>
<instruction> ::= ADD <field-name> <type>
| RENAME <field-name> TO <field-name> ( AND <field-name> TO <field-name> )*
Example
ALTER TYPE address ADD country text
ALTER TYPE address RENAME zip TO zipcode AND street_name TO street
CQL Console Output
cqlsh> CREATE KEYSPACE cassandratutorial WITH REPLICATION =
... {
... 'class' : 'SimpleStrategy',
... 'replication_factor' : 1
... };
cqlsh>
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> ALTER TYPE cassandratutorial.address ADD continent text;
cqlsh>
cqlsh> DESCRIBE TYPE cassandratutorial.address;
CREATE TYPE cassandratutorial.address (
street_name text,
street_number int,
city text,
state text,
country text,
zip int,
continent text
);
No comments:
Post a Comment