alter composite primary key in cassandra CQL 3.0
There is no way to change a primary key, as it defines how your data is physically stored. You can create a new table with the new primary key, copy data from the old one, and then drop the old table.
There is no way to change a primary key, as it defines how your data is physically stored. You can create a new table with the new primary key, copy data from the old one, and then drop the old table.
I think the issue was the result of having a previous installation that wasn’t properly uninstalled. My user .cassandra directory had some default configs, that must have been for a different version, and prevented cqlsh from starting. rm -Rf ~/.cassandra After that, I could run cqlsh properly. $ bin/cqlsh Connected to Test Cluster at 127.0.0.1:9042. … Read more
cqlsh -e “select * from ks.table limit 1;” > ~/output
There are a couple of ways to go about this. From within cqlsh, you can simply show version. aploetz@cqlsh> show version [cqlsh 5.0.1 | Cassandra 2.1.8 | CQL spec 3.2.0 | Native protocol v3] However, that only works from within cqlsh. Fortunately, you can also query system.local for that information as well. aploetz@cqlsh> SELECT cql_version … Read more
To export keyspace schema: cqlsh -e “DESC KEYSPACE user” > user_schema.cql To export entire database schema: cqlsh -e “DESC SCHEMA” > db_schema.cql To import schema open terminal at ‘user_schema.cql’ (‘db_schema.cql’) location (or you can specify the full path) and open cqlsh shell. Then use the following command to import keyspace schema: source ‘user_schema.cql’ To import … Read more
cqlsh> use system; cqlsh:system> select data_center from local; data_center ————- datacenter1
Very simple. Just enter this command in your cqlsh shell and enjoy select * from system.schema_keyspaces; In C*3.x, we can simply use describe keyspaces
You shouldn’t put the quotes around the UUID to stop it being interpreted as a string i.e. insert into devices (device_id, geohash,name, external_identifier, measures, tags) values (c37d661d-7e61-49ea-96a5-68c34e83db3a,’9q9p3yyrn1′, ‘Acme1’, ‘936’, {‘aparPower’,’actPower’,’actEnergy’},{‘make’:’Acme’});
If you don’t mind your data using a pipe (‘|’) as a delimiter, you can try using the -e flag on cqlsh. The -e flag allows you to send a query to Cassandra from the command prompt, where you could redirect or even perform a grep/awk/whatever on your output. $ bin/cqlsh -e’SELECT video_id,title FROM stackoverflow.videos’ … Read more
You need to edit cassandra.yaml on the node you are trying to connect to and set the node ip address for rpc_address and listen_address and restart Cassandra. rpc_address is the address on which Cassandra listens to the client calls. listen_address is the address on which Cassandra listens to the other Cassandra nodes.