cqlsh 使用 cqlsh -e 执行时有问题
cqlsh having issue executing using cqlsh -e
我很难使用 -e 选项执行,列名在引号中。
我想使用 unix 级别执行类似下面的操作。尝试从 shell 脚本 运行。当我尝试将我的值放在引号中时,它会带走我专栏的引号。
select * from keyspace.cf where "columnname"=''
试过这个:
cqlsh hostname -e "select * from keyspace.cf where "columnname"=''"
它作为 cqlsh hostname -e 'select * from keyspace.cf where columnname='
执行
stdin>:1:InvalidRequest: Error from server: code=2200 [Invalid query] message="Undefined name columnaname in where clause ('columnname= 'value'')"
你不需要在 columnname
周围加上引号,你只需要设置它并在它前面加上 $.
cqlsh -u cassandra -p cassandra -e "SELECT $COLUMN FROm $KEYSPACE.$TABLE;"
这是我编写的名为 getVersion.sh
的脚本的摘录。
#!/bin/bash
KEYSPACE="system"
TABLE="local"
COLUMN="release_version"
~/local/apache-cassandra-3.10/bin/cqlsh -u cassandra -p cassandra -e "SELECT $COLUMN FROm $KEYSPACE.$TABLE;"
aploetz@dockingBay94:~/scripts$ ./getVersion.sh
release_version
-----------------
3.10
(1 rows)
如果您的列名包含引号,同样会起作用。请务必在您的变量定义中转义它们。这是一个类似的脚本,但它查询 "columnName" TEXT
列:
#!/bin/bash
KEYSPACE="Whosebug"
TABLE="stuff_with_quotes"
COLUMN="\"columnName\""
~/local/apache-cassandra-3.10/bin/cqlsh -u cassandra -p cassandra -e "SELECT $COLUMN FROm $KEYSPACE.$TABLE;"
我很难使用 -e 选项执行,列名在引号中。
我想使用 unix 级别执行类似下面的操作。尝试从 shell 脚本 运行。当我尝试将我的值放在引号中时,它会带走我专栏的引号。
select * from keyspace.cf where "columnname"=''
试过这个:
cqlsh hostname -e "select * from keyspace.cf where "columnname"=''"
它作为 cqlsh hostname -e 'select * from keyspace.cf where columnname='
执行stdin>:1:InvalidRequest: Error from server: code=2200 [Invalid query] message="Undefined name columnaname in where clause ('columnname= 'value'')"
你不需要在 columnname
周围加上引号,你只需要设置它并在它前面加上 $.
cqlsh -u cassandra -p cassandra -e "SELECT $COLUMN FROm $KEYSPACE.$TABLE;"
这是我编写的名为 getVersion.sh
的脚本的摘录。
#!/bin/bash
KEYSPACE="system"
TABLE="local"
COLUMN="release_version"
~/local/apache-cassandra-3.10/bin/cqlsh -u cassandra -p cassandra -e "SELECT $COLUMN FROm $KEYSPACE.$TABLE;"
aploetz@dockingBay94:~/scripts$ ./getVersion.sh
release_version
-----------------
3.10
(1 rows)
如果您的列名包含引号,同样会起作用。请务必在您的变量定义中转义它们。这是一个类似的脚本,但它查询 "columnName" TEXT
列:
#!/bin/bash
KEYSPACE="Whosebug"
TABLE="stuff_with_quotes"
COLUMN="\"columnName\""
~/local/apache-cassandra-3.10/bin/cqlsh -u cassandra -p cassandra -e "SELECT $COLUMN FROm $KEYSPACE.$TABLE;"