My cassandra database is running as a service. Now I want to add a new keyspace
When I would do it through the CMD/cqlsh it woul look like this:
CREATE KEYSPACE core_meter WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
How can I achieve this when Cassandra is running as a service?
I have a C# program communicating it, can I create a keyspace with C# code?
You can add a new keyspace in code by not calling the keyspace in the session like this:
public void CreateKeyspace()
{
cluster = Cluster.Builder().AddContactPoint("192.168.30.104").Build();
session = cluster.Connect();//
session.Execute("CREATE KEYSPACE acc_meter WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.