Aerospike系列:4:简单的增删改查aql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
[root@localhost bin]# aql --help
Usage: aql OPTIONS
 
OPTIONS
     
     -h <host>
         The hostname to the server connect to . Default : 127.0.0.1
 
     -p <port>
         The port number of the server to connect to . Default : 3000
 
     -U < user name >
         User name used to authenticate with cluster. Default : none
 
     -P[< password >]
         Password used to authenticate with cluster. Default : none
 
         User will be prompted on command line if -P specified and no password is given.
 
     -c <command>
         Execute the specified command.
 
     -f <filepath>
         Execute the commands in the specified file.
 
     -v
         Enable verbose output . Default : disabled
 
     -e
         Enable echoing of commands. Default disabled
 
     -M
         Result display disabled. Default display enabled
 
     -q
         Scan queue size . Default 3
 
     -T <milliseconds>
         Set the timeout (ms) for commands. Default : 1000
 
     -S
         Enable SLAP mode for queries. Default : disabled
 
     -t <n>
         Number of batch threads for SLAP mode. Default : 10
 
     -i <n>
         Number of iterations per thread for SLAP mode. Default : 10
 
     -o (json | table )
         Set the output mode. Default : table
 
     -F <file path>
         Set output file path. Default : /dev/ null
 
     -u <path>
         Path to User managed UDF modules.
         Default : /opt/aerospike/usr/udf/lua
 
     -s <path>
         Path to the System managed UDF modules.
         Default : /opt/aerospike/sys/udf/lua
 
     -d
         Run in debug mode.
 
     --help
         Prints this message.
 
COMMANDS
     
     DDL
         CREATE INDEX < index > ON <ns>[.< set >] (<bin>) NUMERIC |STRING
         CREATE LIST/MAPKEYS/MAVALUES INDEX < index > ON <ns>[.< set >] (<bin>) NUMERIC |STRING
         DROP INDEX <ns>[.< set >] < index >
         REPAIR INDEX < index > ON <ns>[.< set >]
         
             <ns> is the namespace for the index .
             < set > is the set name for the index .
             < index > is the name of the index .
         
         Examples:
         
             CREATE INDEX idx_foo ON test.demo (foo) NUMERIC
             DROP INDEX test.demo idx_foo
             REPAIR INDEX idx_foo ON test.demo
         
     DML
         INSERT INTO <ns>[.< set >] (PK, <bins>) VALUES (< key >, < values >)
         DELETE FROM <ns>[.< set >] WHERE PK = < key >
         
             <ns> is the namespace for the record.
             < set > is the set name for the record.
             < key > is the record 's primary key.
             <key> is the record' s primary key .
             <bins> is a comma-separated list of bin names.
             < values > is comma-separated list of bin values . Keep it NULL ( case insensitive & w/o quotes) to delete the bin
         
         Examples:
         
             INSERT INTO test.demo (PK, foo, bar) VALUES ( 'key1' , 123, 'abc' )
             DELETE FROM test.demo WHERE PK = 'key1'
         
     QUERY
         SELECT <bins> FROM <ns>[.< set >]
         SELECT <bins> FROM <ns>[.< set >] WHERE <bin> = <value>
         SELECT <bins> FROM <ns>[.< set >] WHERE <bin> BETWEEN < lower > AND < upper >
         SELECT <bins> FROM <ns>[.< set >] WHERE PK = < key >
         SELECT <bins> FROM <ns>[.< set >] IN <indextype> WHERE <bin> = <value>
         SELECT <bins> FROM <ns>[.< set >] IN <indextype> WHERE <bin> BETWEEN < lower > AND < upper >
         
             <ns> is the namespace for the records to be queried.
             < set > is the set name for the record to be queried.
             < key > is the record 's primary key.
             <bin> is the name of a bin.
             <value> is the value of a bin.
             <indextype> is the type of a index user wants to query. (LIST/MAPKEYS/MAPVALUES)
             <bins> can be either a wildcard (*) or a comma-separated list of bin names.
             <lower> is the lower bound for a numeric range query.
             <upper> is the lower bound for a numeric range query.
         
         Examples:
         
             SELECT * FROM test.demo
             SELECT * FROM test.demo WHERE PK = ' key1 '
             SELECT foo, bar FROM test.demo WHERE PK = ' key1 '
             SELECT foo, bar FROM test.demo WHERE foo = 123
             SELECT foo, bar FROM test.demo WHERE foo BETWEEN 0 AND 999
         
     MANAGE UDFS
         REGISTER MODULE ' <filepath> '
         SHOW MODULES
         REMOVE MODULE <filename>
         DESC MODULE <filename>
         
             <filepath> is file path to the UDF module(in single quotes).
             <filename> is file name of the UDF module.
         
         Examples:
         
             REGISTER MODULE ' ~/test.lua '
             SHOW MODULES
             DESC MODULE test.lua
             REMOVE MODULE test.lua
         
     INVOKING UDFS
         EXECUTE <module>.<function>(<args>) ON <ns>[.<set>]
         EXECUTE <module>.<function>(<args>) ON <ns>[.<set>] WHERE PK = <key>
         AGGREGATE <module>.<function>(<args>) ON <ns>[.<set>] WHERE <bin> = <value>
         AGGREGATE <module>.<function>(<args>) ON <ns>[.<set>] WHERE <bin> BETWEEN <lower> AND <upper>
         
             <module> is UDF module containing the function to invoke.
             <function> is UDF to invoke.
             <args> is a comma-separated list of argument values for the UDF.
             <ns> is the namespace for the records to be queried.
             <set> is the set name for the record to be queried.
             <key> is the record' s primary key .
             <bin> is the name of a bin.
             <value> is the value of a bin.
             < lower > is the lower bound for a numeric range query.
             < upper > is the lower bound for a numeric range query.
         
         Examples:
         
             EXECUTE myudfs.udf1(2) ON test.demo
             EXECUTE myudfs.udf1(2) ON test.demo WHERE PK = 'key1'
             AGGREGATE myudfs.udf2(2) ON test.demo WHERE foo = 123
             AGGREGATE myudfs.udf2(2) ON test.demo WHERE foo BETWEEN 0 AND 999
         
     INFO
         SHOW NAMESPACES | SETS | BINS | INDEXES
         SHOW SCANS | QUERIES
         STAT NAMESPACE <ns> | INDEX <ns> <indexname>
         STAT SYSTEM
         
     JOB MANAGEMENT
         KILL_QUERY <transaction_id>
         KILL_SCAN <scan_id>
         
     USER ADMINISTRATION
         CREATE USER < user > PASSWORD < password > ROLE[S] <role1>,<role2>...
             pre-defined roles: read | read -write| read -write-udf|sys-admin| user -admin
         DROP USER < user >
         SET PASSWORD < password > [ FOR < user >]
         GRANT ROLE[S] <role1>,<role2>... TO < user >
         REVOKE ROLE[S] <role1>,<role2>... FROM < user >
         CREATE ROLE <role> PRIVILEGE[S] <priv1[.ns1[.set1]]>,<priv2[.ns2[.set2]]>...
             priv: read | read -write| read -write-udf|sys-admin| user -admin
             ns:   namespace.  Applies to all namespaces if not set .
             set set name .  Applie to all sets within namespace if not set .
                   sys-admin and user -admin can't be qualified with namespace or set .
         DROP ROLE <role>
         GRANT PRIVILEGE[S] <priv1[.ns1[.set1]]>,<priv2[.ns2[.set2]]>... TO <role>
         REVOKE PRIVILEGE[S] <priv1[.ns1[.set1]]>,<priv2[.ns2[.set2]]>... FROM <role>
         SHOW USER [< user >]
         SHOW USERS
         SHOW ROLE <role>
         SHOW ROLES
         
     SETTINGS
         TIMEOUT                       ( time in ms, default : 1000 ms)
         RECORD_TTL                    ( time in ms, default : 0 ms)
         VERBOSE                       ( true | false , default false )
         ECHO                          ( true | false , default false )
         FAIL_ON_CLUSTER_CHANGE        ( true | false , default true , policy applies to scans)
         OUTPUT                        ( table | json, default table )
         LUA_USERPATH                  <path>, default : /opt/aerospike/usr/udf/lua
         LUA_SYSPATH                   <path>, default : /opt/aerospike/sys/udf/lua
         
         To get the value of a setting, run:
             
             aql> GET <setting>
             
         To set the value of a setting, run:
             
             aql> SET <setting> <value>
             
     OTHER
         RUN <filepath>
         HELP
         QUIT|EXIT|Q
Aerospike Query
Copyright 2013 Aerospike. All rights reserved.

 

添加一条记录:

?
1
2
aql> INSERT INTO test.set_fir (PK,uid,uname) VALUES ( 'key' ,1, 'Aerospike' )
OK, 1 record affected.

  

查询:

?
1
2
3
4
5
6
7
aql> select * from test.set_fir
+ -----+-------------+
| uid | uname       |
+ -----+-------------+
| 1   | "Aerospike" |
+ -----+-------------+
1 row in set (0.048 secs)

  

 

删除set:test.demo11 中的数据:

?
1
2
aql> DELETE FROM test.set_fir WHERE PK = 'key'
OK, 1 record affected.

也可以:

?
1
2
[root@localhost bin]# asinfo -v "set-config:context=namespace;id=test;set=set_fir;set-delete=true;"
ok

  

 

?
1
2
[root@localhost ~]# asinfo -v "set-config:context=namespace;id=test;set=demo11;set-delete=true;"
ok

  

 

查询:

?
1
2
aql> select * from test.demo11
0 rows in set (0.068 secs)

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值