Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra: can I have default value for a column like sql

Tags:

cassandra

During the creation of a table, like in SQL we have DEFAULT to insert a defualt value for a column. type tinyint(1) NOT NULL DEFAULT '0'

Is there anything to achieve the same in Cassandra .

like image 593
user2681607 Avatar asked Oct 03 '13 09:10

user2681607


People also ask

How DEFAULT clause is used in the table definition?

Use the DEFAULT clause in the CREATE TABLE statement to specify the default value for the database server to insert into a column when no explicit value for the column is specified. This syntax fragment is part of the Column definition.

Can we CREATE TABLE without primary key in Cassandra?

You can't create a table in Cassandra without a primary key, But still if you want to save your data you can add an additional column to your table (let say "pk") with data type UUID.

How many columns does Cassandra support?

Cassandra allows 2 billion columns per row.

How do I add a column to a Cassandra table?

You can add a column in the table by using the ALTER command. While adding column, you have to aware that the column name is not conflicting with the existing column names and that the table is not defined with compact storage option. Syntax: ALTER TABLE table name.


1 Answers

No, there is no default value in Cassandra. Further more, setting a column value to null means removing it

like image 60
doanduyhai Avatar answered Sep 23 '22 00:09

doanduyhai