RENAME oldkey newkey
Atomically renames the key oldkey to newkey. If the source and destination name are the same an error is returned. If newkey already exists it is overwritten.
TIME COMPLEXITY: O(1)
RETURN VALUE: Status code reply
Syntax:
RENAME oldkey newkey
Example 1: When the oldkey is present.
redis:6379> SET redisKey 1000"OK"redis:6379> RENAME redisKey redisKey1"OK"
Output
OK
Example 2: When the oldkey is not present.
redis:6379> RENAME myredis redis(error) no such key
Output
(error) no such key
No comments:
Post a Comment