Previous Next JavaScript must be enabled to correctly display this content

## Using TableRequest API to drop table

You can use TableRequest API to drop a NoSQL table.

Execution of operations specified by`TableRequest` is asynchronous. These are potentially long-running operations. `TableResult` is returned from `TableRequest` operations and it encapsulates the state of the table. See Oracle NoSQL Java SDK API Reference for more details on the `TableRequest` class and its methods.

Download the full code AlterTable.java from the examples here.

    /*Drop the table*/
    private static void dropTab(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");
    }

You can use the `borneo.TableRequest` class to drop a table. All calls to `borneo.NoSQLHandle.table_request()` are asynchronous so it is necessary to check the result and call `borneo.TableResult.wait_for_completion()` to wait for the operation to complete. See Oracle NoSQL Python SDK API Reference for more details on `table_request` and its methods.

Download the full code AlterTable.py from the examples here.

    def drop_table(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')

You can use the `TableRequest` class to drop a table. Execution of operations specified by `TableRequest` is asynchronous. These are potentially long-running operations. This request is used as the input of a `Client.DoTableRequest()` operation, which returns a `TableResult` that can be used to poll until the table reaches the desired state. See Oracle NoSQL Go SDK API Reference for more details on the various methods of the `TableRequest` class.

Download the full code AlterTable.go from the examples here.

    //drop an existing table
    func dropTable(client *nosqldb.Client, err error, tableName string)(){
       stmt := fmt.Sprintf("DROP TABLE %s",tableName)
       tableReq := &nosqldb.TableRequest{
    		Statement: stmt,
       }
       tableRes, err := client.DoTableRequest(tableReq)
       return
    }

You can use the `tableDDL` method to drop a table. This method is asynchronous and it returns a Promise of `TableResult`. The `TableResult` is a plain JavaScript object that encapsulates the state of the table after the DDL operation. For method details, see NoSQLClient class.

Download the full JavaScript code AlterTable.js from the examples here and the full TypeScript code AlterTable.ts from the examples here.

    //drop a table
    async function dropTable(handle) {
       const dropDDL = `DROP TABLE ${TABLE_NAME}`;
       let res =  await handle.tableDDL(dropDDL);
       console.log('Table dropped: ' + TABLE_NAME);
    }

You can use either of the methods `ExecuteTableDDLAsync` or `ExecuteTableDDLWithCompletionAsync` to drop a table. Both the methods return `Task<TableResult>`. `TableResult` instance encapsulates the state of the table after the DDL operation. See Oracle NoSQL Dotnet SDK API Reference for more details on these methods.

Download the full code AlterTable.cs from the examples here.

    private static async Task dropTable(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);
    }