How to switch Keyspace in Cassandra using CQL?
Asked Answered
T

4

9

I used USE billKeyspace; to enter a keyspace and start using it. Now I want to exit this keyspace and enter another keyspace. How to do that?

If I use exit; or quit; it exits out of cql session itself and then I have to connect again.

Torsk answered 4/1, 2017 at 16:31 Comment(2)
use otherKeyspace; ?Tadeo
You are right, that did work actually. When I tried earlier I was not using case sensitive keyspace name so it was failing.Torsk
T
18

To switch keyspaces I didn't find any other way but to use USE otherKeySpace;.

Torsk answered 4/1, 2017 at 19:12 Comment(0)
R
9

You can switch simply by "use" command.

cqlsh>    DESC KEYSPACEs;

system_distributed system_auth system system_traces

cqlsh> use system_distributed;
cqlsh:system_distributed>
cqlsh:system_distributed>
cqlsh:system_distributed> use system_auth;
cqlsh:system_auth>
Rib answered 6/12, 2017 at 11:35 Comment(0)
R
0

You can do it without use USE command, like this:

 select * from KeySpace1.tbl ;
 select * from KeySpace2.tbl ;
Randazzo answered 21/11, 2017 at 10:39 Comment(0)
D
0

You should use quotes around your keyspace name, especially if it contains other symbols than letters.

use "test-space";
Detective answered 30/1, 2023 at 16:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.