Redis Flushall 命令

Redis 服務(wù)器

Redis Flushall 命令用于清空整個 Redis 服務(wù)器的數(shù)據(jù)(刪除所有數(shù)據(jù)庫的所有 key )。

語法

redis Flushall 命令基本語法如下:

redis 127.0.0.1:6379> FLUSHALL 

可用版本

>= 1.0.0

返回值

總是返回 OK 。

實例

redis 127.0.0.1:6379> DBSIZE            # 0 號數(shù)據(jù)庫的 key 數(shù)量
(integer) 9

redis 127.0.0.1:6379> SELECT 1          # 切換到 1 號數(shù)據(jù)庫
OK

redis 127.0.0.1:6379> DBSIZE         # 1 號數(shù)據(jù)庫的 key 數(shù)量
(integer) 6

redis 127.0.0.1:6379> flushall       # 清空所有數(shù)據(jù)庫的所有 key
OK

redis 127.0.0.1:6379> DBSIZE         # 不但 1 號數(shù)據(jù)庫被清空了
(integer) 0

redis 127.0.0.1:6379> SELECT 0       # 0 號數(shù)據(jù)庫(以及其他所有數(shù)據(jù)庫)也一樣
OK

redis 127.0.0.1:6379> DBSIZE
(integer) 0

Redis 服務(wù)器