问题
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:
- Backup the bucket using cbbackup. Then recreate it and restore it using cbrestore.
- 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