user51
user51

Reputation: 10163

Aerospike aql Syntax error near token - Make sure string values are enclosed in quotes

I'm trying to delete the records from aeropike datastore set. I'm using the query language given here.

But looks like the query has syntax error.I've given below the query and respective error.

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

Any idea what is wrong in my query. Thanks in advance.

Upvotes: 0

Views: 1222

Answers (1)

pgupta
pgupta

Reputation: 5415

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

Extending the example further (also showing with key_send set to true) for ease of understanding, showing how truncate works.

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

Upvotes: 4

Related Questions