Aerospike aql令牌附近的语法错误 - 确保字符串值用引号括起来

时间:2018-03-08 22:53:42

标签: aerospike

我正在尝试从aeropike数据存储集中删除记录。 我正在使用here给出的查询语言。

但看起来查询有语法错误。我在下面给出了查询和相应的错误。

Aerospike Query Client
Version 3.13.0.1
C Client Version 4.1.6
Copyright 2012-2016 Aerospike. All rights reserved.
aql> set  TIMEOUT 100000
aql> delete from test.User
Syntax error near token -  'delete from test.User'
Make sure string values are enclosed in quotes.
Type " aql --help " from console or simply "help" from within the aql-prompt.

aql> delete from 'test.User'
Syntax error near token -  'delete from 'test.User''
Make sure string values are enclosed in quotes.
Type " aql --help " from console or simply "help" from within the aql-prompt.

aql> truncate test.User

ERROR: 404: COMMAND NOT FOUND : truncate
aql> truncate test User

ERROR: 404: COMMAND NOT FOUND : truncate
aql> truncate ns

ERROR: 404: COMMAND NOT FOUND : truncate

aql> select '_id' from test.User
+-----------+
| _id       |
+-----------+
| "Dave-02" |
| "Dave-01" |
+-----------+
2 rows in set (1.413 secs)

aql> delete from test.User where '_id'="Dave-01"
Unsupported command format with token -  ''_id''
Make sure string values are enclosed in quotes.
Type " aql --help " from console or simply "help" from within the aql-prompt.


    aql>  show namespaces
    +------------+
    | namespaces |
    +------------+
    | "test"     |
    | "bar"      |
    +------------+
    2 rows in set (0.001 secs)
    OK

    aql> show sets
    +------------------+--------+----------------+---------+-------------------+--------------+-------------------+--------------+------------+
    | disable-eviction | ns     | set-enable-xdr | objects | stop-writes-count | set          | memory_data_bytes | truncate_lut | tombstones |
    +------------------+--------+----------------+---------+-------------------+--------------+-------------------+--------------+------------+
    | "false"          | "test" | "use-default"  | 0       | 0                 | "UserRecord" | 0                 | 0            | 0          |
    | "false"          | "bar"  | "use-default"  | 1       | 0                 | "UserRecord" | 1230              | 0            | 0          |
    +------------------+--------+----------------+---------+-------------------+--------------+-------------------+--------------+------------+
    2 rows in set (0.000 secs)
    OK

知道我的查询中有什么问题。 提前谢谢。

1 个答案:

答案 0 :(得分:4)

aql> insert into ns1.user (pk, name, age) values (1, 'Raj', 24)
OK, 1 record affected.

aql> insert into ns1.user (pk, name, age) values (2, 'Kumar', 24)
OK, 1 record affected.

aql> select * from ns1.user
+---------+-----+
| name    | age |
+---------+-----+
| "Raj"   | 24  |
| "Kumar" | 24  |
+---------+-----+
2 rows in set (0.039 secs)

OK

aql> delete from ns1.user where pk = 1
OK, 1 record affected.

aql> select * from ns1.user
+---------+-----+
| name    | age |
+---------+-----+
| "Kumar" | 24  |
+---------+-----+
1 row in set (0.038 secs)

OK

进一步扩展示例(也显示key_send设置为true)以便于理解,显示truncate如何工作。

aql> set key_send true
KEY_SEND = true
aql> insert into ns1.user (pk, name, age) values (1, 'Raj', 24)
OK, 1 record affected.

aql> insert into ns1.user (pk, name, age) values (2, 'Kumar', 25)
OK, 1 record affected.

aql> select * from ns1.user
+----+---------+-----+
| PK | name    | age |
+----+---------+-----+
| 1  | "Raj"   | 24  |
| 2  | "Kumar" | 25  |
+----+---------+-----+
2 rows in set (0.037 secs)

OK

aql> truncate ns1.user
OK

aql> select * from ns1.user
0 rows in set (0.036 secs)

OK
相关问题