检查表是否存在

检查表是否存在。

代码示例

C++

如需了解如何安装和使用 Bigtable 的客户端库,请参阅 Bigtable 客户端库

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::StatusOr;
[](cbt::TableAdmin admin, std::string const& table_id) {
  StatusOr<google::bigtable::admin::v2::Table> table =
      admin.GetTable(table_id, cbt::TableAdmin::NAME_ONLY);
  if (!table) {
    if (table.status().code() == google::cloud::StatusCode::kNotFound) {
      std::cout << "Table " << table_id << " does not exist\n";
      return;
    }
    throw std::runtime_error(table.status().message());
  }

  std::cout << "Table " << table_id << " was found\n";
}

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器