Manage regions

The show regions statement provides the list of regions present in the Multi-Region Oracle NoSQL Database. You need to specify "AS JSON" if you want the output to be in JSON format.

Example 1: The following statement lists all the existing regions.
SHOW REGIONS
The following statement lists all the existing regions in JSON format.
SHOW AS JSON REGIONS
In a Multi-Region Oracle NoSQL Database environment, the drop region statement removes the specified remote region from the local region. See Set up Multi-Region Environment for more details on the local regions and remote regions in a Multi-Region setup.

Note:

This region must be different from the local region where the command is executed.
The following drop region statement removes a remote region named my_region1.
DROP REGION my_region1

Using APIs to drop regions:

You can drop a region using SystemRequest class. The SystemRequest class is used to perform any table-independent administrative operation. You can use the TableRequest class to drop tables.

Download the full code Regions.java from the examples here.
/* Drop a table from a region*/
private static void dropTabInRegion(NoSQLHandle handle) throws Exception {
   String dropTableDDL = "DROP TABLE " + tableName;
   TableRequest treq = new TableRequest().setStatement(dropTableDDL);
   TableResult tres = handle.tableRequest(treq);
   tres.waitForCompletion(handle, 60000, /* wait 60 sec */
   1000); /* delay ms for poll */
   System.out.println("Table " + tableName + " is dropped");
}
   /* Drop a region*/
   private static void dropRegion(NoSQLHandle handle, String regName) throws Exception {
      String dropNSDDL = "DROP REGION " + regName;
      SystemRequest sysreq = new SystemRequest();
      sysreq.setStatement(dropNSDDL.toCharArray());
      SystemResult sysres = handle.systemRequest​(sysreq);
      sysres.waitForCompletion​(handle, 60000,1000);
      System.out.println("Region " + regName + " is dropped");
   }

You can drop a region using SystemRequest class. The SystemRequest class is used to perform any table-independent administrative operations. You can drop a table using the borneo.TableRequest class.

Download the full code Regions.py from the examples here.
#Drop the table from a region
def drop_tab_region(handle):
   statement = '''DROP TABLE stream_acct'''
   request = TableRequest().set_statement(statement)
   table_result = handle.do_table_request(request, 40000, 3000)
   table_result.wait_for_completion(handle, 40000, 3000)
   print('Dropped table: stream_acct')

#Drop the region
def drop_region(handle):
   statement = '''DROP REGION LON'''
   sysreq = SystemRequest().set_statement(statement)
   sys_result = handle.system_request(sysreq)
   sys_result.wait_for_completion(handle, 40000, 3000)
   print('Region LON is dropped')

You can drop a region using SystemRequest class. The SystemRequest class is used to perform any table-independent administrative operations. You can drop a table using TableRequest class.

Download the full code Regions.go from the examples here.
//drops a table from a region
func drpTabInRegion(client *nosqldb.Client, err error, tableName string)(){
   stmt := fmt.Sprintf("DROP TABLE %s",tableName)
   tableReq := &nosqldb.TableRequest{
		Statement: stmt,
   }
   tableRes, err := client.DoTableRequest(tableReq)
   if err != nil {
      fmt.Printf("cannot initiate DROP TABLE request: %v\n", err)
      return
   }
   _, err = tableRes.WaitForCompletion(client, 60*time.Second, time.Second)
   if err != nil {
      fmt.Printf("Error finishing DROP TABLE request: %v\n", err)
      return
   }
   fmt.Println("Dropped table ", tableName)
   return
}

//drop a region
func dropRegion(client *nosqldb.Client, err error)(){
   stmt := fmt.Sprintf("DROP REGION LON")
   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 DROP REGION request: %v\n", err)
      return
   }
   fmt.Println("Dropped REGION LON ")
   return
}

You can drop a region using adminDDL method. The adminDDL module is used to perform an administrative operation on the system. You can drop a table using the tableDDL method.

Download the full JavaScript code Regions.js from the examples here and the full TypeScript code Regions.ts from the examples here.
//drop a table from a region
async function dropTabInRegion(handle) {
   const dropDDL = `DROP TABLE ${TABLE_NAME}`;
   let res =  await handle.tableDDL(dropDDL);
   console.log('Table dropped: ' + TABLE_NAME);
}

//drop a region
async function dropRegion(handle) {
   const dropReg = `DROP REGION LON`;
   let res = await handle.adminDDL(dropReg);
   console.log('Region dropped: LON' );
}

You can use ExecuteAdminSync method to drop a region. The ExecuteAdminSync method is used to perform an administrative operation on the system. You can drop a table using either ExecuteTableDDLAsync or ExecuteTableDDLWithCompletionAsync.

Download the full code Regions.cs from the examples here.
private static async Task dropTabInRegion(NoSQLClient client){
   var sql = $@"DROP TABLE {TableName}";
   var tableResult = await client.ExecuteTableDDLAsync(sql);
   // Wait for the operation completion
   await tableResult.WaitForCompletionAsync();
   Console.WriteLine("  Table {0} is dropped", tableResult.TableName);
}

private static async Task dropRegion(NoSQLClient client){
   var sql = $@"DROP REGION LON";
   var adminResult = await client.ExecuteAdminAsync(sql);
   // Wait for the operation completion
   await adminResult.WaitForCompletionAsync();
   Console.WriteLine("  Dropped region LON");
}