SQL窗口
更新时间:2024-10-25
本文介绍如何使用 SQL 窗口。
前提条件
- 实例已接入 DBSC,且接入状态为接入成功。
- 数据源类型必须为下列其中之一:MySQL、GaiaDB、GaiaDB-X、Redis。
-
开启企业版后,您必须拥有目标数据源的只读、DML 或 DDL 权限。
注意:
只读权限仅支持查看数据库以及 SELECT 操作。
限制说明
- 仅 Redis 4.0.0 及以上版本支持显示 Key 的大小(Size)。
- 仅 Redis 5.0.0 及以上版本支持管理 Stream 类型的 Key。
功能介绍
SQL 窗口提供多个便捷功能,帮助您轻松管理您的数据源。
功能 | 说明 |
---|---|
执行 SQL 语句 | |
生成创建脚本 | 支持针对数据源中已有的库、表、触发器、存储过程、事件、函数等对象生成创建脚本,用于在其他数据源中复制一个相同结构的对象等场景。 |
可视化表结构设计 | 以可视化的方式创建表或编辑表。 |
保存 SQL|查看 SQL | 对于常用 SQL,您可以将 SQL 保存,保存后的 SQL 也支持查看。 |
Redis 可视化管理 | 支持以可视化的方式进行如下操作: |
Redis 编辑器 | 提供命令行模式,支持 Redis 功能强大的命令和选项,可以满足各种不同的需求。编辑器支持的 Redis 命令请参见 附录。 |
工作现场恢复 | 对于浏览器意外退出或突发宕机等场景,您只需要重新登录 DBSC 控制台并打开 SQL 窗口,之前打开的数据源以及执行过的 SQL 命令会被自动加载。 |
SQL 执行历史 | 执行历史会记录当前账号在 DBSC 控制台执行过的所有 SQL 语句,还支持根据数据源、执行时间、SQL 关键字等方式快速检索。您也可以快速复制执行历史中的 SQL 语句重新在 SQL 窗口中执行。 |
SQL 规范检查 | 在企业版模式下,系统会基于系统管理员配置的 SQL 开发规范检查每一条在 SQL 窗口中执行的 SQL,如果该条 SQL 不符合规范,则会被系统拦截,保证数据库安全。拦截后,根据系统管理员配置的审批流程,用户可以按照规范修改 SQL 重新提交,或直接提交 SQL 任务。 |
操作步骤
- 登录 DBSC 控制台。
- 在左侧导航栏,点击 数据开发—>SQL 窗口。
- 单击 SQL 窗口下方文本框,会弹出可用的数据源,单击目标数据源,并单击开始查询,跳转到 SQL 窗口。
- 打开 SQL 窗口后,即可对数据源执行数据开发操作。SQL 窗口的详细使用方法,请参见 SQL 窗口界面介绍。
SQL窗口界面介绍
序号 | 功能 | 介绍 |
---|---|---|
1 | SQL 窗口页签 | 表示当前已打开的数据源 SQL 窗口,多个 SQL 窗口可以通过单击页签切换,单击页签右侧的X可以关闭该 SQL 窗口。右键菜单支持如下操作: |
2 | 打开数据源 | 选择并打开新的数据源 SQL 窗口。 |
3 | 数据源信息 | 展示当前 SQL 窗口的数据源信息,包含环境、IP 地址以及端口号。 右键菜单: |
4 | 收藏|刷新 | |
5 | 数据库名称 | 选中目标数据库以执行 SQL 操作。 切换 Redis 数据库或集群模式下的节点地址。右键菜单: |
6 | 功能按钮 |
|
7 | 搜索 | |
8 | 数据库列表 | |
9 | Key 列表 | 显示当前数据库中的 Key,默认加载 100 条。如需加载更多,可以拖动列表到队列最后,单击加载更多即可再加载 100 条。在 Key 列表中,您可以对 Key 做如下操作: |
10 | SQL 编辑器 | 支持如下功能:
|
11 | 创建 Key | 创建新的 Key。单击创建 Key,打开创建 Key 页签,您可以根据实际需求选择 Key 类型,不同 Key 类型的创建选项不同,请根据页面提示进行配置,配置完成后单击创建 Key 即可。说明*:如需关闭创建 Key** 页签,直接单击页签右侧的关闭图标。 |
12 | 执行信息、结果集 | 显示 SQL 的执行信息以及结果集。
|
13 | Key 详情 | 在 Key 列表中单击某个 Key,即可在此处显示该 Key 的详情。Key 中数据超出 100 条的,默认仅加载 100 条,单击页面底部的加载更多可再加载 100 条。在 Key 详情中您可以对 Key 进行如下操作:
|
附录:Redis支持的命令列表
Bitmap
关键字 | 支持版本 | 命令格式 |
---|---|---|
BITCOUNT | 2.6.0 | BITCOUNT key [start end] |
BITFIELD | 3.2.0 | BITFIELD key [GET type offset] [SET type offset value] [INCRBY type offset increment] [OVERFLOW WRAP|SAT|FAIL] |
BITFIELD_RO | 6.0.0 | BITFIELD_RO key [GET encoding offset [GET encoding offset ...]] |
BITOP | 2.6.0 | BITOP <AND | OR | XOR | NOT> destkey key [key ...] |
BITPOS | 2.8.7 | BITPOS key bit [start [end [BYTE | BIT]]] |
GETBIT | 2.2.0 | GETBIT key offset |
SETBIT | 2.2.0 | SETBIT key offset value |
Connection Management
关键字 | 支持版本 | 命令格式 |
---|---|---|
SELECT | 1.0.0 | SELECT index |
Generic
关键字 | 支持版本 | 命令格式 |
---|---|---|
COPY | 6.2.0 | COPY source destination [DB destination-db] [REPLACE] |
DEL | 1.0.0 | DEL key [key ...] |
DUMP | 2.6.0 | DUMP key |
EXISTS | 1.0.0 | EXISTS key [key ...] |
EXPIRE | 1.0.0 | EXPIRE key seconds [NX | XX | GT | LT] |
EXPIREAT | 1.2.0 | EXPIREAT key unix-time-seconds [NX | XX | GT | LT] |
EXPIRETIME | 7.0.0 | EXPIRETIME key |
MIGRATE | 2.6.0 | MIGRATE host port <key | ""> destination-db timeout [COPY] [REPLACE] [AUTH password | AUTH2 username password] [KEYS key [key ...]] |
MOVE | 1.0.0 | MOVE key db |
OBJECT ENCODING | 2.3.3 | OBJECT ENCODING key |
OBJECT FREQ | 4.0.0 | OBJECT FREQ key |
OBJECT IDLETIME | 2.2.3 | OBJECT IDLETIME key |
OBJECT REFCOUNT | 2.2.3 | OBJECT REFCOUNT key |
PERSIST | 2.2.0 | PERSIST key |
PEXPIRE | 2.6.0 | PEXPIRE key milliseconds [NX | XX | GT | LT] |
PEXPIREAT | 2.6.0 | PEXPIREAT key unix-time-milliseconds [NX | XX | GT | LT] |
PEXPIRETIME | 7.0.0 | PEXPIRETIME key |
PTTL | 2.6.0 | PTTL key |
RANDOMKEY | 1.0.0 | RANDOMKEY |
RENAME | 1.0.0 | RENAME key newkey |
RENAMENX | 1.0.0 | RENAMENX key newkey |
RESTORE | 2.6.0 | RESTORE key ttl serialized-value [REPLACE] [ABSTTL] [IDLETIME seconds] [FREQ frequency] |
SCAN | 2.8.0 | SCAN cursor [MATCH pattern] [COUNT count] [TYPE type] |
SORT | 1.0.0 | SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC | DESC] [ALPHA] [STORE destination] |
SORT_RO | 7.0.0 | SORT_RO key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC | DESC] [ALPHA] |
TOUCH | 3.2.1 | TOUCH key [key ...] |
TTL | 1.0.0 | TTL key |
TYPE | 1.0.0 | TYPE key |
UNLINK | 4.0.0 | UNLINK key [key ...] |
Cluster management
关键字 | 支持版本 | 命令格式 |
---|---|---|
ASKING | 3.0.0 | ASKING |
CLUSTER ADDSLOTS | 3.0.0 | CLUSTER ADDSLOTS slot [slot ...] |
CLUSTER ADDSLOTSRANGE | 7.0.0 | CLUSTER ADDSLOTSRANGE start-slot end-slot [start-slot end-slot ...] |
CLUSTER BUMPEPOCH | 3.0.0 | CLUSTER BUMPEPOCH |
CLUSTER COUNT-FAILURE-REPORTS | 3.0.0 | CLUSTER COUNT-FAILURE-REPORTS node-id |
CLUSTER COUNTKEYSINSLOT | 3.0.0 | CLUSTER COUNTKEYSINSLOT slot |
CLUSTER DELSLOTS | 3.0.0 | CLUSTER DELSLOTS slot [slot ...] |
CLUSTER DELSLOTSRANGE | 7.0.0 | CLUSTER DELSLOTSRANGE start-slot end-slot [start-slot end-slot ...] |
CLUSTER FLUSHSLOTS | 3.0.0 | CLUSTER FLUSHSLOTS |
CLUSTER FORGET | 3.0.0 | CLUSTER FORGET node-id |
CLUSTER GETKEYSINSLOT | 3.0.0 | CLUSTER GETKEYSINSLOT slot count |
CLUSTER INFO | 3.0.0 | CLUSTER INFO |
CLUSTER KEYSLOT | 3.0.0 | CLUSTER KEYSLOT key |
CLUSTER LINKS | 7.0.0 | CLUSTER LINKS |
CLUSTER MEET | 3.0.0 | CLUSTER MEET ip port [cluster-bus-port] |
CLUSTER MYID | 3.0.0 | CLUSTER MYID |
CLUSTER MYSHARDID | 7.2.0 | CLUSTER MYSHARDID |
CLUSTER NODES | 3.0.0 | CLUSTER NODES |
CLUSTER REPLICAS | 5.0.0 | CLUSTER REPLICAS node-id |
CLUSTER REPLICATE | 3.0.0 | CLUSTER REPLICATE node-id |
CLUSTER RESET | 3.0.0 | CLUSTER RESET [HARD | SOFT] |
CLUSTER SAVECONFIG | 3.0.0 | CLUSTER SAVECONFIG |
CLUSTER SET-CONFIG-EPOCH | 3.0.0 | CLUSTER SET-CONFIG-EPOCH config-epoch |
CLUSTER SETSLOT | 3.0.0 | CLUSTER SETSLOT slot <IMPORTING node-id | MIGRATING node-id | NODE node-id | STABLE> |
CLUSTER SHARDS | 7.0.0 | CLUSTER SHARDS |
CLUSTER SLAVES | 3.0.0 | CLUSTER SLAVES node-id |
CLUSTER SLOTS | 3.0.0 | CLUSTER SLOTS |
READONLY | 3.0.0 | READONLY |
READWRITE | 3.0.0 | READWRITE |
Geospatial Indices
关键字 | 支持版本 | 命令格式 |
---|---|---|
GEOADD | 3.2.0 | GEOADD key [NX | XX] [CH] longitude latitude member [longitude latitude member ...] |
GEODIST | 3.2.0 | GEODIST key member1 member2 [M | KM | FT | MI] |
GEOHASH | 3.2.0 | GEOHASH key [member [member ...]] |
GEOPOS | 3.2.0 | GEOPOS key [member [member ...]] |
GEORADIUS | 3.2.0 | GEORADIUS key longitude latitude radius <M | KM | FT | MI> [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC] [STORE key] [STOREDIST key] |
GEO RADIUS_RO | 3.2.10 | GEORADIUS_RO key longitude latitude radius <M | KM | FT | MI> [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC] |
GEORADIUS BYMEMBER | 3.2.0 | GEORADIUSBYMEMBER key member radius <M | KM | FT | MI> [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC] [STORE key] [STOREDIST key] |
GEORADIUS BYMEMBER_RO | 3.2.10 | GEORADIUSBYMEMBER_RO key member radius <M | KM | FT | MI> [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC] |
GEOSEARCH | 6.2.0 | GEOSEARCH key <FROMMEMBER member | FROMLONLAT longitude latitude> <BYRADIUS radius <M | KM | FT | MI> | BYBOX width height <M | KM | FT | MI>> [ASC | DESC] [COUNT count [ANY]] [WITHCOORD] [WITHDIST] [WITHHASH] |
GEOSEARCH STORE | 6.2.0 | GEOSEARCHSTORE destination source <FROMMEMBER member | FROMLONLAT longitude latitude> <BYRADIUS radius <M | KM | FT | MI> | BYBOX width height <M | KM | FT | MI>> [ASC | DESC] [COUNT count [ANY]] [STOREDIST] |
Hash
关键字 | 支持版本 | 命令格式 |
---|---|---|
HDEL | 2.0.0 | HDEL key field [field ...] |
HEXISTS | 2.0.0 | HEXISTS key field |
HGET | 2.0.0 | HGET key field |
HGETALL | 2.0.0 | HGETALL key |
HINCRBY | 2.0.0 | HINCRBY key field increment |
HINCRBYFLOAT | 2.6.0 | HINCRBYFLOAT key field increment |
HKEYS | 2.0.0 | HKEYS key |
HLEN | 2.0.0 | HLEN key |
HMGET | 2.0.0 | HMGET key field [field ...] |
HMSET | 2.0.0 | HMSET key field value [field value ...] |
HRANDFIELD | 6.2.0 | HRANDFIELD key [count [WITHVALUES]] |
HSET | 2.0.0 | HSET key field value |
HSETNX | 2.0.0 | HSETNX key field value |
HVALS | 2.0.0 | HVALS key |
HSCAN | 2.8.0 | HSCAN key cursor [MATCH pattern] [COUNT count] |
HSTRLEN | 3.2.0 | HSTRLEN key field |
HyperLogLog
关键字 | 支持版本 | 命令格式 |
---|---|---|
PFADD | 2.8.9 | PFADD key [element [element ...]] |
PFCOUNT | 2.8.9 | PFCOUNT key [key ...] |
PFMERGE | 2.8.9 | PFMERGE destkey [sourcekey [sourcekey ...]] |
List
关键字 | 支持版本 | 命令格式 |
---|---|---|
LINDEX | 1.0.0 | LINDEX key index |
LINSERT | 2.2.0 | LINSERT key <BEFORE | AFTER> pivot element |
LLEN | 1.0.0 | LLEN key |
LMOVE | 6.2.0 | LMOVE source destination <LEFT | RIGHT> <LEFT | RIGHT> |
LMPOP | 7.0.0 | LMPOP numkeys key [key ...] <LEFT | RIGHT> [COUNT count] |
LPOP | 1.0.0 | LPOP key [count] |
LPOS | 6.0.6 | LPOS key element [RANK rank] [COUNT num-matches] [MAXLEN len] |
LPUSH | 1.0.0 | LPUSH key element [element ...] |
LPUSHX | 2.2.0 | LPUSHX key element [element ...] |
LRANGE | 1.0.0 | LRANGE key start stop |
LREM | 1.0.0 | LREM key count element |
LSET | 1.0.0 | LSET key index element |
LTRIM | 1.0.0 | LTRIM key start stop |
RPOP | 1.0.0 | RPOP key [count] |
RPOPLPUSH | 1.2.0 | RPOPLPUSH source destination |
RPUSH | 1.0.0 | RPUSH key element [element ...] |
RPUSHX | 2.2.0 | RPUSHX key element [element ...] |
Set
关键字 | 支持版本 | 命令格式 |
---|---|---|
SADD | 1.0.0 | SADD key member [member ...] |
SCARD | 1.0.0 | SCARD key |
SDIFF | 1.0.0 | SDIFF key [key ...] |
SDIFFSTORE | 1.0.0 | SDIFFSTORE destination key [key ...] |
SINTER | 1.0.0 | SINTER key [key ...] |
SINTERCARD | 7.0.0 | SINTERCARD numkeys key [key ...] [LIMIT limit] |
SINTERSTORE | 1.0.0 | SINTERSTORE destination key [key ...] |
SISMEMBER | 1.0.0 | SISMEMBER key member |
SMEMBERS | 1.0.0 | SMEMBERS key |
SMISMEMBER | 6.2.0 | SMISMEMBER key member [member ...] |
SMOVE | 1.0.0 | SMOVE source destination member |
SPOP | 1.0.0 | SPOP key [count] |
SRANDMEMBER | 1.0.0 | SRANDMEMBER key [count] |
SREM | 1.0.0 | SREM key member [member ...] |
SSCAN | 2.8.0 | SSCAN key cursor [MATCH pattern] [COUNT count] |
SUNION | 1.0.0 | SUNION key [key ...] |
SUNIONSTORE | 1.0.0 | SUNIONSTORE destination key [key ...] |
SortedSet
关键字 | 支持版本 | 命令格式 |
---|---|---|
ZADD | 1.2.0 | ZADD key [NX | XX] [GT | LT] [CH] [INCR] score member [score member ...] |
ZCARD | 1.2.0 | ZCARD key |
ZCOUNT | 2.0.0 | ZCOUNT key min max |
ZDIFF | 6.2.0 | ZDIFF numkeys key [key ...] [WITHSCORES] |
ZDIFFSTORE | 6.2.0 | ZDIFFSTORE destination numkeys key [key ...] |
ZINCRBY | 1.2.0 | ZINCRBY key increment member |
ZINTER | 6.2.0 | ZINTER numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE <SUM | MIN | MAX>] [WITHSCORES] |
ZINTERCARD | 7.0.0 | ZINTERCARD numkeys key [key ...] [LIMIT limit] |
ZINTERSTORE | 2.0.0 | ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE <SUM | MIN | MAX>] |
ZLEXCOUNT | 2.8.9 | ZLEXCOUNT key min max |
ZMPOP | 7.0.0 | ZMPOP numkeys key [key ...] <MIN | MAX> [COUNT count] |
ZMSCORE | 6.2.0 | ZMSCORE key member [member ...] |
ZPOPMAX | 5.0.0 | ZPOPMAX key [count] |
ZPOPMIN | 5.0.0 | ZPOPMIN key [count] |
ZRAND MEMBER | 6.2.0 | ZRANDMEMBER key [count [WITHSCORES]] |
ZRANGE | 1.2.0 | ZRANGE key start stop [BYSCORE | BYLEX] [REV] [LIMIT offset count] [WITHSCORES] |
ZRANGEBYLEX | 2.8.9 | ZRANGEBYLEX key min max [LIMIT offset count] |
ZRANGE BYSCORE | 1.0.5 | ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count] |
ZRANGESTORE | 6.2.0 | ZRANGESTORE dst src min max [BYSCORE | BYLEX] [REV] [LIMIT offset count] |
ZRANK | 2.0.0 | ZRANK key member [WITHSCORE] |
ZREM | 1.2.0 | ZREM key member [member ...] |
ZREMRANGE BYLEX | 2.8.9 | ZREMRANGEBYLEX key min max |
ZREMRANGE BYRANK | 2.0.0 | ZREMRANGEBYRANK key start stop |
ZREMRANGE BYSCORE | 1.2.0 | ZREMRANGEBYSCORE key min max |
ZREVRANGE | 1.2.0 | ZREVRANGE key start stop [WITHSCORES] |
ZREVRANGE BYLEX | 2.8.9 | ZREVRANGEBYLEX key max min [LIMIT offset count] |
ZREVRANGE BYSCORE | 2.2.0 | ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count] |
ZREVRANK | 2.0.0 | ZREVRANK key member [WITHSCORE] |
ZSCAN | 2.8.0 | ZSCAN key cursor [MATCH pattern] [COUNT count] |
ZSCORE | 1.2.0 | ZSCORE key member |
ZUNION | 6.2.0 | ZUNION numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE <SUM | MIN | MAX>] [WITHSCORES] |
ZUNIONSTORE | 2.0.0 | ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE <SUM | MIN | MAX>] |
Stream
关键字 | 支持版本 | 命令格式 |
---|---|---|
XACK | 5.0.0 | XACK key group id [id ...] |
XAUTOCLAIM | 6.2.0 | XAUTOCLAIM key group consumer min-idle-time start [COUNT count] [JUSTID] |
XCLAIM | 5.0.0 | XCLAIM key group consumer min-idle-time id [id ...] [IDLE ms] [TIME unix-time-milliseconds] [RETRYCOUNT count] [FORCE] [JUSTID] [LASTID lastid] |
XDEL | 5.0.0 | XDEL key id [id ...] |
XGROUP CREATE | 5.0.0 | XGROUP CREATE key group <id | $> [MKSTREAM] [ENTRIESREAD entries-read] |
XGROUP CREATECONSUMER | 6.2.0 | XGROUP CREATECONSUMER key group consumer |
XGROUP DELCONSUMER | 5.0.0 | XGROUP DELCONSUMER key group consumer |
XGROUP DESTROY | 5.0.0 | XGROUP DESTROY key group |
XGROUP SETID | 5.0.0 | XGROUP SETID key group <id | $> [ENTRIESREAD entries-read] |
XINFO CONSUMERS | 5.0.0 | XINFO CONSUMERS key group |
XINFO GROUPS | 5.0.0 | XINFO GROUPS key |
XINFO STREAM | 5.0.0 | XINFO STREAM key [FULL [COUNT count]] |
XLEN | 5.0.0 | XLEN key |
XPENDING | 5.0.0 | XPENDING key group [[IDLE min-idle-time] start end count [consumer]] |
XRANGE | 5.0.0 | XRANGE key start end [COUNT count] |
XREVRANGE | 5.0.0 | XREVRANGE key end start [COUNT count] |
XTRIM | 5.0.0 | XTRIM key <MAXLEN | MINID> [= | ~] threshold [LIMIT count] |
String
关键字 | 支持版本 | 命令格式 |
---|---|---|
APPEND | 2.0.0 | APPEND key value |
DECR | 1.0.0 | DECR key |
DECRBY | 1.0.0 | DECRBY key decrement |
GET | 1.0.0 | GET key |
GETDEL | 6.2.0 | GETDEL key |
GETEX | 6.2.0 | GETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | PERSIST] |
GETRANGE | 2.4.0 | GETRANGE key start end |
GETSET | 1.0.0 | GETSET key value |
INCR | 1.0.0 | INCR key |
INCRBY | 1.0.0 | INCRBY key increment |
INCRBYFLOAT | 2.6.0 | INCRBYFLOAT key increment |
LCS | 7.0.0 | LCS key1 key2 [LEN] [IDX] [MINMATCHLEN min-match-len] [WITHMATCHLEN] |
MGET | 1.0.0 | MGET key [key ...] |
MSET | 1.0.1 | MSET key value [key value ...] |
MSETNX | 1.0.1 | MSETNX key value [key value ...] |
PSETEX | 2.6.0 | PSETEX key milliseconds value |
SET | 1.0.0 | SET key value [NX | XX] [GET] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL] |
SETEX | 2.0.0 | SETEX key seconds value |
SETNX | 1.0.0 | SETNX key value |
SETRANGE | 2.2.0 | SETRANGE key offset value |
STRLEN | 2.2.0 | STRLEN key |
SUBSTR | 1.0.0 | SUBSTR key start end |