Stay organized with collections
Save and categorize content based on your preferences.
Create an instance and write data with the cbt CLI
If you're learning about Bigtable, you can work through a quickstart
to get a taste of the fundamentals that you would use at scale in a production
environment.
In this quickstart, you perform the following actions:
Connect to a Bigtable instance.
Perform basic administrative tasks.
Write data to a table.
Read data from a table.
Before you begin
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
Configure the
cbt CLI
to use your project and instance by creating a
.cbtrc file, replacing PROJECT_ID with the ID
for the project where you created your Bigtable instance:
Two timestamped values are stored for the same column in row r1.
Clean up
To avoid incurring charges to your Google Cloud account for the resources
used in this quickstart, delete the instance. Deleting the .cbtrc file leaves
you ready to work on a different project.
[[["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"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eThis guide demonstrates how to use the \u003ccode\u003ecbt\u003c/code\u003e CLI to interact with a Bigtable instance, which is a fundamental skill for working with Bigtable at any scale.\u003c/p\u003e\n"],["\u003cp\u003eThe quickstart covers essential administrative actions, including creating a Bigtable instance, connecting to it using the \u003ccode\u003ecbt\u003c/code\u003e CLI, and configuring the connection via the \u003ccode\u003e.cbtrc\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eIt walks you through writing data to a table, where you define row keys, column families, and column qualifiers, and then it shows how to read that data back using the \u003ccode\u003ecbt read\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eThe guide also includes steps for cleanup, such as deleting the created table, the instance, and the configuration file (\u003ccode\u003e.cbtrc\u003c/code\u003e), along with an optional step to revoke credentials.\u003c/p\u003e\n"],["\u003cp\u003eYou can find more information about Bigtable, including codelabs, reference documentation, sample source code, and multiple 'hello world' examples on the provided links.\u003c/p\u003e\n"]]],[],null,["# Quickstart: Create an instance and write data with the cbt CLI\n\nCreate an instance and write data with the cbt CLI\n==================================================\n\nIf you're learning about Bigtable, you can work through a quickstart\nto get a taste of the fundamentals that you would use at scale in a production\nenvironment.\n\nIn this quickstart, you perform the following actions:\n\n- Connect to a Bigtable instance.\n- Perform basic administrative tasks.\n- Write data to a table.\n- Read data from a table.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n- [Create or select a Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n - Create a Google Cloud project:\n\n ```\n gcloud projects create PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with a name for the Google Cloud project you are creating.\n - Select the Google Cloud project that you created:\n\n ```\n gcloud config set project PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your Google Cloud project name.\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Bigtable and Cloud Bigtable Admin APIs:\n\n\n ```bash\n gcloud services enable bigtable.googleapis.com bigtableadmin.googleapis.com\n ```\n-\n Grant roles to your user account. Run the following command once for each of the following\n IAM roles:\n `roles/bigtable.admin`\n\n ```bash\n gcloud projects add-iam-policy-binding PROJECT_ID --member=\"user:\u003cvar translate=\"no\"\u003eUSER_IDENTIFIER\u003c/var\u003e\" --role=ROLE\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID.\n - \u003cvar translate=\"no\"\u003eUSER_IDENTIFIER\u003c/var\u003e: the identifier for your user account---for example, `myemail@example.com`.\n - \u003cvar translate=\"no\"\u003eROLE\u003c/var\u003e: the IAM role that you grant to your user account.\n\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n- [Create or select a Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n - Create a Google Cloud project:\n\n ```\n gcloud projects create PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with a name for the Google Cloud project you are creating.\n - Select the Google Cloud project that you created:\n\n ```\n gcloud config set project PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your Google Cloud project name.\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Bigtable and Cloud Bigtable Admin APIs:\n\n\n ```bash\n gcloud services enable bigtable.googleapis.com bigtableadmin.googleapis.com\n ```\n-\n Grant roles to your user account. Run the following command once for each of the following\n IAM roles:\n `roles/bigtable.admin`\n\n ```bash\n gcloud projects add-iam-policy-binding PROJECT_ID --member=\"user:\u003cvar translate=\"no\"\u003eUSER_IDENTIFIER\u003c/var\u003e\" --role=ROLE\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID.\n - \u003cvar translate=\"no\"\u003eUSER_IDENTIFIER\u003c/var\u003e: the identifier for your user account---for example, `myemail@example.com`.\n - \u003cvar translate=\"no\"\u003eROLE\u003c/var\u003e: the IAM role that you grant to your user account.\n\n1. Run the following command to install the `cbt` CLI : \n\n gcloud components install cbt\n\n\u003cbr /\u003e\n\nCreate a Bigtable instance\n--------------------------\n\n1. Open the **Create instance** page in the Google Cloud console.\n\n [Create an instance](https://console.cloud.google.com/bigtable/create-instance)\n2. For **Instance name** , enter `Quickstart instance`.\n\n3. For **Instance ID** , enter `quickstart-instance`.\n\n4. Click **Continue**.\n\n5. For **Storage type** , select **SSD**.\n\n6. Click **Continue**.\n\n7. For **Cluster ID** , enter `quickstart-instance-c1`.\n\n8. For **Region**, select a region near you.\n\n9. For **Zone** , select **Any**.\n\n10. For **Node scaling mode** , choose **Manual allocation**.\n\n11. For **Quantity** , select **1**.\n\n12. Click **Create** to create the instance.\n\nConnect to your instance\n------------------------\n\n1. Configure the\n `cbt` CLI\n to use your project and instance by creating a\n `.cbtrc` file, replacing \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the ID\n for the project where you created your Bigtable instance:\n\n ```\n echo project = PROJECT_ID \u003e\u003e ~/.cbtrc && echo instance = quickstart-instance \u003e\u003e ~/.cbtrc\n ```\n2. Verify that you set up the `.cbtrc` file correctly:\n\n ```\n cat ~/.cbtrc\n ```\n\n The terminal displays the contents of the `.cbtrc` file, which looks similar\n to the following: \n\n ```\n project = PROJECT_ID\n instance = quickstart-instance\n ```\n\n Now you can use the\n `cbt` CLI\n with your instance.\n\nRead and write data\n-------------------\n\nBigtable stores data in *tables* , which contain *rows* . Each row\nis identified by a *row key*.\n\nData in a row is organized into *column families* , which are groups of columns.\nA *column qualifier* identifies a single column within a column family.\n\nThere can be multiple time-stamped cells at the intersection of\na row and column.\n\n1. Create a table named `my-table`.\n\n ```\n cbt createtable my-table\n ```\n2. List your tables:\n\n ```\n cbt ls\n ```\n\n The command displays output similar to the following:\n\n \u003cbr /\u003e\n\n ```\n my-table\n ```\n\n \u003cbr /\u003e\n\n3. Add one column family named `cf1`:\n\n ```\n cbt createfamily my-table cf1\n ```\n4. List your column families:\n\n ```\n cbt ls my-table\n ```\n\n The command displays output similar to the following:\n\n \u003cbr /\u003e\n\n ```\n Family Name GC Policy\n ----------- ---------\n cf1 \u003cnever\u003e\n ```\n\n \u003cbr /\u003e\n\n5. Write the values `test-value1` and `test-value2` to the row `r1`, using the\n column family `cf1` and the column qualifier `c1`:\n\n ```\n cbt set my-table r1 cf1:c1=test-value1\n cbt set my-table r1 cf1:c1=test-value2\n ```\n6. Use the `cbt read` command to read the data you added to the table:\n\n ```\n cbt read my-table\n ```\n\n The shell displays output similar to the following:\n\n \u003cbr /\u003e\n\n ```\n ----------------------------------------\n r1\n cf1:c1 @ 2023/03/22-06:56:11.323000\n \"test-value1\"\n cf1:c1 @ 2023/03/22-06:56:04.361000\n \"test-value2\"\n ```\n\n \u003cbr /\u003e\n\n Two timestamped values are stored for the same column in row `r1`.\n | **Note:** In this quickstart you set only two cells, but Bigtable lets you set up to 10,000 cells in a single write request.\n\nClean up\n--------\n\nTo avoid incurring charges to your Google Cloud account for the resources\nused in this quickstart, delete the instance. Deleting the `.cbtrc` file leaves\nyou ready to work on a different project.\n\n1. Delete the table `my-table`:\n\n ```\n cbt deletetable my-table\n ```\n2. Delete the instance:\n\n ```\n cbt deleteinstance quickstart-instance\n ```\n3. Delete the `.cbtrc` file:\n\n ```\n rm ~/.cbtrc\n ```\n\n \u003cbr /\u003e\n\n4. Optional: Revoke credentials from the gcloud CLI:\n\n ```\n gcloud auth revoke\n ```\n\nWhat's next\n-----------\n\n- Work through a [Bigtable codelab](https://codelabs.developers.google.com/codelabs/cloud-bigtable-intro-java/index.html).\n- View the [`cbt` CLI\n reference documentation](/bigtable/docs/cbt-reference).\n- See sample source code for a [fraud detection use case](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/bigtable/use-cases/fraudDetection).\n- Write a Hello World application in [C#](/bigtable/docs/samples-c-sharp-hello), [C++](/bigtable/docs/samples-cpp-hello), [Go](/bigtable/docs/samples-go-hello), [Java](/bigtable/docs/samples-java-hello-world), [Node.js](/bigtable/docs/samples-nodejs-hello), [PHP](/bigtable/docs/samples-php-hello), [Python](/bigtable/docs/samples-python-hello), [Ruby](/bigtable/docs/samples-ruby-hello), or using the [HBase client for Java](/bigtable/docs/samples-hbase-java-hello)."]]