Database Reference
In-Depth Information
Changing the data type
Changing the data type of a column is possible as long the new data type is compatible
with the old (existing) one, ideally superset. For example, ASCII can be converted to
VARCHAR and VARCHAR to TEXT. Here's an example:
# A table with a clustering column and index
CREATE TABLE type_changer (id int, name ascii, age ascii,
primary key(id, age));
CREATE INDEX tc_idx ON type_changer (name);
# Alter the clustering column
ALTER TABLE type_changer ALTER age TYPE varchar;
# Insert some data
INSERT INTO type_changer (id, age, name) VALUES ( 1, '12',
'Mercedes');
# Alter everything
ALTER TABLE type_changer ALTER age TYPE text;
ALTER TABLE type_changer ALTER name TYPE varchar;
ALTER TABLE type_changer ALTER id TYPE varint;
Dropping a column
Dropping an existing column is simple. Adding the dropped column again does not bring
the data back. You drop a column as follows:
ALTER TABLE table_name DROP column_name;
Updating the table properties
Table properties can be updated the same way they are done when the table is created.
Here is the query format:
ALTER TABLE table_name WITH property [ AND property …];
Search WWH ::




Custom Search