Manage Namespaces
SHOW NAMESPACES
The SHOW NAMESPACES statement provides the list of namespaces in the system. You can specify AS JSON if you want the output to be in JSON format.
SHOW NAMESPACESnamespaces
sysdefaultSHOW AS JSON NAMESPACES{"namespaces" : ["sysdefault"]}DROP NAMESPACE
You can remove a namespace by using the DROP NAMESPACE statement.
IF EXISTS is an optional clause. If you specify this clause, and if a namespace with the same name does not exist, no error is generated. If you don't specify this clause, and if a namespace with the same name does not exist, an error is generated indicating that the namespace does not exist.
CASCADE is an optional clause that enables you to specify whether to drop the tables and their indexes in this namespace. If you specify this clause, and if the namespace contains any tables, then the namespace together with all the tables in this namespace will be deleted. If you don't specify this clause, and if the namespace contains any tables, then an error is generated indicating that the namespace is not empty.
DROP NAMESPACE IF EXISTS ns1 CASCADEUsing APIs to drop namespaces:
You can drop a namespace using SystemRequest class.
The SystemRequest class is used to perform any
table-independent administrative operation. These operations are asynchronous
and completion needs to be checked.
private static void dropNS(NoSQLHandle handle) throws Exception {
String dropNSDDL = "DROP NAMESPACE " + nsName;
SystemRequest sysreq = new SystemRequest();
sysreq.setStatement(dropNSDDL.toCharArray());
SystemResult sysres = handle.systemRequest​(sysreq);
sysres.waitForCompletion​(handle, 60000,1000);
System.out.println("Namespace " + nsName + " is dropped");
}You can drop a namespace using SystemRequest class.
The SystemRequest class is used to perform any
table-independent administrative operation.
def drop_ns(handle):
statement = '''DROP NAMESPACE ns1'''
sysreq = SystemRequest().set_statement(statement)
sys_result = handle.system_request(sysreq)
sys_result.wait_for_completion(handle, 40000, 3000)
print('Namespace: ns1 is dropped')You can drop a namespace using SystemRequest class.
The SystemRequest class is used to perform any
table-independent administrative operations. These are potentially long-running
operations and completion of the operation needs to be checked.
func dropNS(client *nosqldb.Client, err error)(){
stmt := fmt.Sprintf("DROP NAMESPACE ns1")
sysReq := &nosqldb.SystemRequest{
Statement: stmt,
}
sysRes, err := client.DoSystemRequest(sysReq)
_, err = sysRes.WaitForCompletion(client, 60*time.Second, time.Second)
if err != nil {
fmt.Printf("Error finishing CREATE NAMESPACE request: %v\n", err)
return
}
fmt.Println("Dropped Namespace ns1 ")
return
}You can create namespace using adminDDL method. The
adminDDL method is used to perform any table-independent
administrative operation.
The ExecuteAdminSync method is used to perform any
table-independent administrative operations.
private static async Task dropNS(NoSQLClient client){
var sql = $@"DROP NAMESPACE ns1";
var adminResult = await client.ExecuteAdminAsync(sql);
// Wait for the operation completion
await adminResult.WaitForCompletionAsync();
Console.WriteLine("Dropped namespace ns1");
}