Delete a table
Stay organized with collections
Save and categorize content based on your preferences.
Delete a table.
Explore further
For detailed documentation that includes this code sample, see the following:
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides code samples demonstrating how to delete a table in Bigtable using various programming languages.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples are available in C++, C#, Go, Java, Node.js, PHP, Python, and Ruby, each illustrating the deletion process within its respective language.\u003c/p\u003e\n"],["\u003cp\u003eTo use these code samples, it's necessary to set up Application Default Credentials for authentication, as outlined in the documentation.\u003c/p\u003e\n"],["\u003cp\u003eThe page references resources for installing Bigtable client libraries and explores other code samples in the Google Cloud sample browser.\u003c/p\u003e\n"]]],[],null,["Delete a table.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [C# hello world](/bigtable/docs/samples-c-sharp-hello)\n- [C++ hello world](/bigtable/docs/samples-cpp-hello)\n- [Go hello world](/bigtable/docs/samples-go-hello)\n- [Java hello world](/bigtable/docs/samples-java-hello-world)\n- [Node.js hello world](/bigtable/docs/samples-nodejs-hello)\n- [PHP hello world](/bigtable/docs/samples-php-hello)\n- [Python hello world](/bigtable/docs/samples-python-hello)\n- [Ruby hello world](/bigtable/docs/samples-ruby-hello)\n\nCode sample \n\nC++\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n google::cloud::Status status = table_admin.DeleteTable(table.table_name());\n if (!status.ok()) throw std::runtime_error(status.message());\n\nC#\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n // Clean up. Delete the table.\n Console.WriteLine($\"Delete table: {tableId}\");\n\n bigtableTableAdminClient.DeleteTable(name: tableName);\n if (!TableExist(bigtableTableAdminClient))\n {\n Console.WriteLine($\"Table: {tableId} deleted successfully\");\n }\n\nGo\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n log.Printf(\"Deleting the table\")\n if err = adminClient.DeleteTable(ctx, tableName); err != nil {\n \tlog.Fatalf(\"Could not delete table %s: %v\", tableName, err)\n }\n\n if err = adminClient.Close(); err != nil {\n \tlog.Fatalf(\"Could not close admin client: %v\", err)\n }\n\nJava\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n System.out.println(\"\\nDeleting table: \" + tableId);\n try {\n adminClient.deleteTable(tableId);\n System.out.printf(\"Table %s deleted successfully%n\", tableId);\n } catch (NotFoundException e) {\n System.err.println(\"Failed to delete a non-existent table: \" + e.getMessage());\n }\n\nNode.js\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n console.log('Delete the table');\n await table.delete();\n\nPHP\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n try {\n printf('Attempting to delete table %s.' . PHP_EOL, $tableId);\n $deleteTableRequest = (new DeleteTableRequest())\n -\u003esetName($tableName);\n $tableAdminClient-\u003edeleteTable($deleteTableRequest);\n printf('Deleted %s table.' . PHP_EOL, $tableId);\n } catch (ApiException $e) {\n if ($e-\u003egetStatus() === 'NOT_FOUND') {\n printf('Table %s does not exists' . PHP_EOL, $tableId);\n } else {\n throw $e;\n }\n }\n\nPython\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n print(\"Deleting the {} table.\".format(table_id))\n table.delete()\n\nRuby\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n puts \"Deleting the table #{table_id}\"\n # Call the admin API to delete the table given its full resource path.\n table_client.delete_table name: table_name\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=bigtable)."]]