绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
Aerospike系列:4:简单的增删改查aql
2022-04-14 10:12:31
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 toDefault: 127.0.0.1
 
    -p <port>
        The port number of the server to connect toDefault: 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 outputDefault: disabled
 
    -e
        Enable echoing of commands. Default disabled
 
    -M
        Result display disabled. Default display enabled
 
    -q
        Scan queue sizeDefault 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. Defaulttable
 
    -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 <indexON <ns>[.<set>] (<bin>) NUMERIC|STRING
        CREATE LIST/MAPKEYS/MAVALUES INDEX <indexON <ns>[.<set>] (<bin>) NUMERIC|STRING
        DROP INDEX <ns>[.<set>] <index>
        REPAIR INDEX <indexON <ns>[.<set>]
         
            <ns> is the namespace for the index.
            <setis the set name for the index.
            <indexis 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.
            <setis the set name for the record.
            <keyis the record's primary key.
            <key> is the record'primary key.
            <bins> is a comma-separated list of bin names.
            <valuesis 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 <lowerAND <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 <lowerAND <upper>
         
            <ns> is the namespace for the records to be queried.
            <setis the set name for the record to be queried.
            <keyis 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'primary key.
            <bin> is the name of a bin.
            <value> is the value of a bin.
            <loweris the lower bound for numeric range query.
            <upperis the lower bound for 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 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 <userPASSWORD <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 falsedefault false)
        ECHO                          (true falsedefault false)
        FAIL_ON_CLUSTER_CHANGE        (true falsedefault 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
rows in set (0.068 secs)
分享好友

分享这个小栈给你的朋友们,一起进步吧。

Aerospike
创建时间:2022-04-14 10:06:31
Aerospike
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • LCR_
    专家
戳我,来吐槽~