リージョンの管理
show regions
文は、複数リージョンのOracle NoSQL Databaseに存在するリージョンのリストを提供します。出力をJSON形式にする場合は、AS JSONを指定する必要があります。
SHOW REGIONS
SHOW AS JSON REGIONS
ノート:
このリージョンは、コマンドが実行されるローカル・リージョンと異なっている必要があります。DROP REGION my_region1
APIの使用によるリージョンの削除:
SystemRequest
クラスを使用してリージョンを削除できます。SystemRequest
クラスは、表に依存しない管理操作を実行するために使用します。TableRequest
クラスを使用して表を削除できます。
/* 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");
}
SystemRequest
クラスを使用してリージョンを削除できます。SystemRequest
クラスは、表に依存しない管理操作を実行するために使用します。borneo.TableRequest
クラスを使用して表を削除できます。
#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')
SystemRequest
クラスを使用してリージョンを削除できます。SystemRequest
クラスは、表に依存しない管理操作を実行するために使用します。TableRequest
クラスを使用して表を削除できます。
//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
}
adminDDL
メソッドを使用してリージョンを削除できます。adminDDL
モジュールは、システム上で管理操作を実行するために使用します。tableDDL
メソッドを使用して表を削除できます。
//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' );
}
ExecuteAdminSync
メソッドを使用してリージョンを削除できます。ExecuteAdminSync
メソッドは、システム上で管理操作を実行するために使用します。ExecuteTableDDLAsync
またはExecuteTableDDLWithCompletionAsync
を使用して表を削除できます。
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");
}