i would like to know how to use CQL to insert a new column to a row...
Is it possible? If not, how can i do that easily by using Fluent Cassandra?
Thanks.
i would like to know how to use CQL to insert a new column to a row...
Is it possible? If not, how can i do that easily by using Fluent Cassandra?
Thanks.
CQL expects you to define your schema up front. If you want dynamic schema, you must use one of the Thrift-based clients. Fluent Cassandra supports this; check here.
Using FluentCassandra, you can add a new column to an existing row quite easily:
var cFamily = db.GetColumnFamily("TestCF");
cFamily.InsertColumn(rowKey, columnName, columnValue);
Alternatively, you can do it like this:
var cFamily = db.GetColumnFamily("TestCF");
var record = cFamily.CreateRecord(existingRowKey) //record already exists
record[newColumnName] = newColumnValue;
Using FluentCassandra:
dbcontext.ExecuteNonQuery("update TargetColumnFamily set 'ColumnName'='ColumnValue'
where keyname='RowKeyValue'")
In my testing, I've found this will create the row if it doesn't exist. Not sure how to tweak this for non-text.