How to rename a bucket in couchbase?

核能气质少年 提交于 2019-12-10 19:19:03

问题


I have a bucket name 0001 when I use the following N1QL statement I get a "5000" syntax error:

cbq> Select * from 0001;
{
    "requestID": "f2b70856-f80c-4c89-ab37-740e82d119b5",
    "errors": [
        {
            "code": 5000,
            "msg": "syntax error"
        }
    ],
    "status": "fatal",
    "metrics": {
        "elapsedTime": "349.733us",
        "executionTime": "204.442us",
        "resultCount": 0,
        "resultSize": 0,
        "errorCount": 1
    }
}

I think it takes 0001 as a number and not as a bucket name, is there an easy way to rename it?


回答1:


In this case you can use back ticks in N1QL to escape the bucket name:

cbq> Select * from `0001`;
{
    "requestID": "f48527e6-6035-47e7-a34f-90efe9f90d4f",
    "signature": {
        "*": "*"
    },
    "results": [
        {
            "0001": {
                "Hello": "World"
            }
        }
    ],
    "status": "success",
    "metrics": {
        "elapsedTime": "2.410929ms",
        "executionTime": "2.363788ms",
        "resultCount": 1,
        "resultSize": 80
    }
}

Currently there is noway to rename a bucket instead you could do one of the following:

  1. Backup the bucket using cbbackup. Then recreate it and restore it using cbrestore.
  2. Create a second cluster and use XDCR to transfer the data to the new cluster with the correctly named bucket.



回答2:


There is no way I am seeing to rename. I checked the CLI as well and nothing. Your best bet, if you can, is to create a new bucket with the settings you want and then use cbtransfer to move the data over from the old to the new bucket. This is an online operation.



来源:https://stackoverflow.com/questions/29637985/how-to-rename-a-bucket-in-couchbase

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!