DROP COLLECTION
- reference
- Couchbase Server 7.0
The DROP COLLECTION
statement enables you to delete a named collection from a scope.
Syntax
drop-collection ::= DROP COLLECTION [ [ namespace ':' ] bucket '.' scope '.' ] collection
- namespace
-
(Optional) An identifier that refers to the namespace of the bucket which contains the collection you want to delete. Currently, only the
default
namespace is available. If the namespace name is omitted, the default namespace in the current session is used. - bucket
-
(Optional) An identifier that refers to the bucket which contains the collection you want to delete.
- scope
-
(Optional) An identifier that refers to the scope which contains the collection you want to delete.
- collection
-
(Required) An identifier that refers to the name of the collection that you want to delete.
If there is a hyphen (-) inside the bucket name, the scope name, or the collection name, you must wrap that part of the path in backticks (` `).
For example, default:`travel-sample` indicates the travel-sample keyspace in the default namespace.
|
Usage
To specify the collection, you may do one of the following:
-
Include its full path, containing the namespace, bucket, and scope, followed by the collection name;
-
Include a relative path, containing just the bucket and scope, followed by the connection name;
-
Specify just the collection name without a path.
When you specify a collection name without a path, you must set the query context to indicate the required namespace, bucket, and scope. If you specify a collection name by itself without setting a valid query context, an error is generated.
Examples
This statement deletes a collection called city
in the inventory
scope within the travel-sample
bucket.
DROP COLLECTION `travel-sample`.inventory.city
Query Context
For the following example, you must first set the query context to `travel-sample`.inventory
, using the Query Workbench or the cbq shell.
-
Query Workbench
-
CBQ Shell
Use the query context drop-down menu to select travel-sample.inventory
.
\SET -query_context travel-sample.inventory;
Assuming that the query context is set, this statement deletes a collection called country
in the inventory
scope within the travel-sample
bucket.
DROP COLLECTION country;
Related Links
-
An overview of scopes and collections is provided in Scopes and Collections.
-
Step-by-step procedures for management are provided in Manage Scopes and Collections.
-
Refer to Scopes and Collections API to manage scopes and collections with the REST API.
-
Refer to the reference page for the collection-manage command to manage scopes and collections with the CLI.