Create bucket using N1QL

n1ql
#1

How to create bucket using N1QL from cbq-shell.

I want to create a bucket named “test” using N1QL like

create bucket test;

Something like this. Is there any way to do this?

I have a requirement to create, delete bucket.

#2

Hi, Good question and I can see where you’re coming from. We do not provide CREATE syntax for bucket at this point and the reason being we want to keep the manageability aspect only through REST API or CLI. You would have to use /pools/default/bucket REST API or bucket-create CLI command to create bucket. Hope that helps answer your question.
Anil Kumar

1 Like
#3

Note that in addition to @anil’s answer, the SDKs also expose a cluster management class that can create and manage buckets for you. If you’re planning to ultimately use you N1QL queries in Java, C#, Node.js, PHP, you may want to do this from the application code. Let me know what language you plan to use and I can give a more specific pointer.

1 Like
#4

We are using Java SDK @ingenthr

#5

Hi @anil, bucket-create CLI command is working and it satisfies my current need. Thank you :smile: