Manage tables (original) (raw)
Discover
Get started
Plan
Datasets
Tables
- External data sources
* Introduction
* External tables
* Introduction
* Create Apache Iceberg external tables
* Create Bigtable external tables
* Create Cloud Storage external tables
* Create Google Drive external tables
* Use metadata caching
* Manage Hive partitioned data
* Create a table definition file for external data - Apache Iceberg managed tables
- External data sources
Load, transform, and export
Migrate data
- Introduction
- BigQuery Migration Service
- Migration assessment
- Migrate schema and data
- Migrate data pipelines
- Use custom organization policies
- Migrate SQL
* Translate SQL queries interactively
* Translate SQL queries using the API
* Translate SQL queries in batch
* Generate metadata for translation and assessment
* Transform SQL translations with YAML
* Map SQL object names for batch translation
Load data
- Introduction
- Create data integration workflows using the BigQuery web UI
- Storage overview
- BigQuery Data Transfer Service
* Introduction
* Supported data sources
* Data location and transfers
* Authorize transfers
* Enable transfers
* Manage transfers
* Transfer run notifications
* Troubleshoot transfer configurations
* Use service accounts
* Use third-party transfers
* Use custom organization policies
* Data source change log
* Event-driven transfers
* Transfer data into Managed Iceberg tables - Batch load data
* Introduction
* Auto-detect schemas
* Load Avro data
* Load Parquet data
* Load ORC data
* Load CSV data
* Load JSON data
* Load externally partitioned data
* Load data from a Datastore export
* Load data from a Firestore export
* Load data using the Storage Write API
* Load data into partitioned tables - Load data from other Google services
- Discover and catalog Cloud Storage data
- Load data using third-party apps
- Load data using BigQuery Omni operations
- Optimize load jobs
Export data
Analyze
Analyze your data
- Run a query
- Write queries with Gemini
- Write query results
- Query data with SQL
* Introduction
* Arrays
* JSON data
* Multi-statement queries
* Parameterized queries
* Pipe syntax
* Analyze data using pipe syntax
* Recursive CTEs
* Sketches
* Table sampling
* Time series
* Transactions
* Wildcard tables - Use DataFrames
* Introduction
* Install DataFrames
* Manipulate data
* Customize Python functions
* Use ML and AI
* Use the data type system
* Manage sessions and I/O
* Visualize graphs
* Use DataFrames in dbt
* Optimize performance
* Migrate to DataFrames version 2.0
* Use the BigQuery JupyterLab plugin - Routines
* Introduction
* Manage routines
* User-defined functions
* User-defined functions in Python
* User-defined aggregate functions
* Table functions
* Remote functions
* SQL stored procedures
* Stored procedures for Apache Spark
* Analyze object tables by using remote functions
* Remote functions and Translation API tutorial - Run global queries
- Access historical data
- Use open source Python libraries
Use BigQuery Graph
Manage queries
- Use cached results
- Troubleshoot queries
- Optimize queries
* Introduction
* Use the query plan explanation
* Get query performance insights
* Optimize query computation
* Use history-based optimizations
* Optimize storage for query performance
* Use materialized views
* Use BI Engine
* Use nested and repeated data
* Optimize functions
* Use the advanced runtime
* Use primary and foreign keys - Paginate with the BigQuery API
Query external data sources
- Establish connections
* Introduction
* Create connections
* Create a Cloud resource connection
* Create a default Cloud resource connection
* AlloyDB connections
* Amazon S3 connections
* Apache Spark connections
* Azure Blob Storage connections
* Cloud SQL connections
* SAP Datasphere connections
* Spanner connections
* Manage connections
* Configure connections with network attachments - Run queries on external data
- Establish connections
BigQuery AI
Generative AI functions
- Overview
- End-to-end user journeys for generative AI models
- Choose a text generation function
- Set permissions for generative AI functions
- Optimize costs with model distillation
- Tutorials
* Generate text
* Generate text with Gemini
* Generate text with Gemma
* Generate text with any supported model
* Generate text using AI.GENERATE
* Handle quota errors
* Analyze images
* Perform semantic analysis
* Computer vision
* Annotate images
* Run inference on image data
* Analyze images with an imported classification model
* Analyze images with an imported feature vector model
Embeddings and vector search
- Overview
- Vector indexes
- Manage vector indexes
- Automate embedding generation
- Tutorials
* Generate embeddings
* Generate text embeddings using a remote model
* Generate text embeddings using an open model
* Generate image embeddings using an LLM
* Generate video embeddings using an LLM
* Handle quota errors by calling ML.GENERATE_EMBEDDING iteratively
* Generate and search multimodal embeddings
* Generate text embeddings using pretrained TensorFlow models
* Generate embeddings with transformer models in ONNX format
Machine learning
- Introduction
- ML models and MLOps
* Model creation
* Hyperparameter tuning overview
* Model evaluation overview
* Model inference overview
* Explainable AI overview
* Model weights overview
* ML pipelines overview
* Model monitoring overview
* Manage BigQueryML models in Agent Platform - Classification
- Regression
- Dimensionality reduction
- Clustering
- Recommendation
- Forecasting
- Anomaly detection
- Contribution analysis
- Tutorials
* Recommendation
* Create recommendations based on explicit feedback with a matrix factorization model
* Create recommendations based on implicit feedback with a matrix factorization model
* Augmented analytics
* Forecasting
* Forecast a single time series with an ARIMA_PLUS univariate model
* Forecast multiple time series with an ARIMA_PLUS univariate model
* Forecast time series with a TimesFM univariate model
* Scale an ARIMA_PLUS univariate model to millions of time series
* Forecast a single time series with a multivariate model
* Forecast multiple time series with a multivariate model
* Use custom holidays with an ARIMA_PLUS univariate model
* Limit forecasted values for an ARIMA_PLUS univariate model
* Forecast hierarchical time series with an ARIMA_PLUS univariate model
Administer
Monitor workloads
Govern
Share data
Audit
Develop
Version control with repositories and workspaces
You can manage BigQuery tables to control their lifecycle, optimize storage costs, and ensure data governance. Table management includes tasks such as updating properties, renaming, copying, and deleting tables. When you update BigQuery table properties, you can modify their expiration time, description, schema definition, labels, and default rounding mode.
To restore a deleted table, see Restore deleted tables. To learn more about creating and using tables, including getting table information, listing tables, and controlling access to table data, seeCreating and using tables.
Before you begin
Grant Identity and Access Management (IAM) roles that give users the necessary permissions to perform each task in this document. The permissions required to perform a task (if any) are listed in the "Required permissions" section of the task.
Update table properties
You can update the following elements of a table:
Required permissions
To get the permissions that you need to update table properties, ask your administrator to grant you theData Editor (roles/bigquery.dataEditor) IAM role on a table. For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to update table properties. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to update table properties:
bigquery.tables.updatebigquery.tables.get
You might also be able to get these permissions with custom roles or other predefined roles.
Additionally, if you have the bigquery.datasets.create permission, you can update the properties of the tables of the datasets that you create.
Update a table's description
You can update a table's description in the following ways:
- Using the Google Cloud console.
- Using a data definition language (DDL)
ALTER TABLEstatement. - Using the bq command-line tool's
bq updatecommand. - Calling the tables.patchAPI method.
- Using the client libraries.
- Generating a description with Gemini in BigQuery.
To update a table's description:
Console
You can't add a description when you create a table using the Google Cloud console. After the table is created, you can add a description on the Details page.
- In the left pane, click Explorer:

If you don't see the left pane, click Expand left pane to open the pane. - In the Explorer pane, expand your project, click Datasets, and then select a dataset.
- Click Overview > Tables, and then select a table.
- Click the Details tab, and then click Edit details.
- In the Description section, add a new description or edit an existing description.
- Click Save.
SQL
Use theALTER TABLE SET OPTIONS statement. The following example updates the description of a table named mytable:
- In the Google Cloud console, go to the BigQuery page.
Go to BigQuery - In the query editor, enter the following statement:
ALTER TABLE mydataset.mytable
SET OPTIONS (
description = 'Description of mytable'); - Click Run.
For more information about how to run queries, see Run an interactive query.
bq
- In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. - Issue the
bq updatecommand with the--descriptionflag. If you are updating a table in a project other than your default project, add the project ID to the dataset name in the following format:project_id:dataset.
bq update \
--description "description" \
project_id:dataset.table
Replace the following:description: the text describing the table in quotesproject_id: your project IDdataset: the name of the dataset that contains the table you're updatingtable: the name of the table you're updating
Examples:
To change the description of themytabletable in themydatasetdataset to "Description of mytable", enter the following command. Themydatasetdataset is in your default project.
bq update --description "Description of mytable" mydataset.mytable
To change the description of themytabletable in themydatasetdataset to "Description of mytable", enter the following command. Themydatasetdataset is in themyotherprojectproject, not your default project.
bq update \
--description "Description of mytable" \
myotherproject:mydataset.mytable
API
Call the tables.patchmethod and use the description property in the table resourceto update the table's description. Because the tables.update method replaces the entire table resource, the tables.patch method is preferred.
Go
Before trying this sample, follow the Go setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Go API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
Before trying this sample, follow the Java setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Java API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
Before trying this sample, follow the Python setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Python API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Configure the Table.descriptionproperty and call Client.update_table()to send the update to the API.
Gemini
You can generate a table description with Gemini in BigQuery by using data insights. Data insights is an automated way to explore, understand, and curate your data.
For more information about data insights, including setup steps, required IAM roles, and best practices to improve the accuracy of the generated insights, seeGenerate data insights in BigQuery.
- In the Google Cloud console, go to the BigQuery page.
Go to BigQuery - In the left pane, click Explorer:

- In the Explorer pane, expand your project and dataset, then select the table.
- In the details panel, click the Schema tab.
- Click Generate.
Gemini generates a table description and insights about the table. It takes a few minutes for the information to be populated. You can view the generated insights on the table'sInsights tab. - To edit and save the generated table description, do the following:
- Click View column descriptions.
The current table description and the generated description are displayed. - In the Table description section, click Save to details.
- To replace the current description with the generated description, click Copy suggested description.
- Edit the table description as necessary, and then clickSave to details.
The table description is updated immediately. - To close the Preview descriptions panel, clickClose.
- Click View column descriptions.
Update a table's expiration time
You can set a default table expiration time at the dataset level, or you can set a table's expiration time when the table is created. A table's expiration time is often referred to as "time to live" or TTL.
When a table expires, it is deleted along with all of the data it contains. If necessary, you can undelete the expired table within the time travel window specified for the dataset, seeRestore deleted tables for more information.
If you set the expiration when the table is created, the dataset's default table expiration is ignored. If you do not set a default table expiration at the dataset level, and you do not set a table expiration when the table is created, the table never expires and you must delete the table manually.
At any point after the table is created, you can update the table's expiration time in the following ways:
- Using the Google Cloud console.
- Using a data definition language (DDL)
ALTER TABLEstatement. - Using the bq command-line tool's
bq updatecommand. - Calling the tables.patchAPI method.
- Using the client libraries.
To update a table's expiration time:
Console
You can't add an expiration time when you create a table using the Google Cloud console. After a table is created, you can add or update a table expiration on the Table Details page.
- In the left pane, click Explorer:

- In the Explorer pane, expand your project, click Datasets, and then select a dataset.
- Click Overview > Tables, and then select a table.
- Click the Details tab and the click Edit details.
- For Expiration time, select Specify date. Then select the expiration date using the calendar widget.
- Click Save. The updated expiration time appears in theTable info section.
SQL
Use theALTER TABLE SET OPTIONS statement. The following example updates the expiration time of a table named mytable:
- In the Google Cloud console, go to the BigQuery page.
Go to BigQuery - In the query editor, enter the following statement:
ALTER TABLE mydataset.mytable
SET OPTIONS (
-- Sets table expiration to timestamp 2025-02-03 12:34:56
expiration_timestamp = TIMESTAMP '2025-02-03 12:34:56'); - Click Run.
For more information about how to run queries, see Run an interactive query.
bq
- In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. - Issue the
bq updatecommand with the--expirationflag. If you are updating a table in a project other than your default project, add the project ID to the dataset name in the following format:project_id:dataset.
bq update \
--expiration integer \project_id:dataset.table
Replace the following:integer: the default lifetime (in seconds) for the table. The minimum value is 3600 seconds (one hour). The expiration time evaluates to the current time plus the integer value. If you specify0, the table expiration is removed, and the table never expires. Tables with no expiration must be manually deleted.project_id: your project ID.dataset: the name of the dataset that contains the table you're updating.table: the name of the table you're updating.
Examples:
To update the expiration time of themytabletable in themydatasetdataset to 5 days (432000 seconds), enter the following command. Themydatasetdataset is in your default project.
bq update --expiration 432000 mydataset.mytable
To update the expiration time of themytabletable in themydatasetdataset to 5 days (432000 seconds), enter the following command. Themydatasetdataset is in themyotherprojectproject, not your default project.
bq update --expiration 432000 myotherproject:mydataset.mytable
API
Call the tables.patchmethod and use the expirationTime property in the table resourceto update the table expiration in milliseconds. Because the tables.updatemethod replaces the entire table resource, the tables.patch method is preferred.
Go
Before trying this sample, follow the Go setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Go API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
Before trying this sample, follow the Java setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Java API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
Before trying this sample, follow the Node.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Node.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
Before trying this sample, follow the Python setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Python API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Configure Table.expiresproperty and call Client.update_table()to send the update to the API.
To update the default dataset partition expiration time:
Update a table's rounding mode
You can update a table'sdefault rounding modeby using theALTER TABLE SET OPTIONS DDL statement. The following example updates the default rounding mode for mytable toROUND_HALF_EVEN:
ALTER TABLE mydataset.mytable SET OPTIONS ( default_rounding_mode = "ROUND_HALF_EVEN");
When you add a NUMERIC or BIGNUMERIC field to a table and do not specify a rounding mode, then the rounding mode is automatically set to the table's default rounding mode. Changing a table's default rounding mode doesn't alter the rounding mode of existing fields.
Update a table's schema definition
For more information about updating a table's schema definition, seeModifying table schemas.
Rename a table
You can rename a table after it has been created by using theALTER TABLE RENAME TO statement. The following example renames mytable to mynewtable:
ALTER TABLE mydataset.mytable RENAME TO mynewtable;
The ALTER TABLE RENAME TO statement recreates the table in the destination dataset with the creation timestamp of the original table. If you have configured dataset-level table expiration, the renamed table might be immediately deleted if its original creation timestamp falls outside of the expiration window.
Limitations on renaming tables
- If you want to rename a table that has data streaming into it, you must stop the streaming, commit any pending streams, and wait for BigQuery to indicate that streaming is not in use.
- While a table can usually be renamed 5 hours after the last streaming operation, it might take longer.
- Existing table ACLs and row access policies are preserved, but table ACL and row access policy updates made during the table rename are not preserved.
- You can't concurrently rename a table and run a DML statement on that table.
- Renaming a table removes allData Catalog tags(deprecated) and Knowledge Catalog aspectson the table.
- Any search index or vector index created on the table is dropped when the table is renamed.
- You can't rename external tables.
Copy a table
This section describes how to create a full copy of a table. For information about other types of table copies, see table clones andtable snapshots.
You can copy a table in the following ways:
- Use the Google Cloud console.
- Use the bq cp command.
- Use a data definition language (DDL)CREATE TABLE COPYstatement.
- Call the jobs.insertAPI method and configure a
copyjob. - Use the client libraries.
Limitations on copying tables
Table copy jobs are subject to the following limitations:
- You can't stop a table copy operation after you start it. A table copy operation runs asynchronously and doesn't stop even when you cancel the job. You are also charged for data transfer for a cross-region table copy and for storage in the destination region.
- When you copy a table, the name of the destination table must adhere to the same naming conventions as when you create a table.
- Table copies are subject to BigQuerylimits on copy jobs.
- The Google Cloud console supports copying only one table at a time. You can't overwrite an existing table in the destination dataset. The table must have a unique name in the destination dataset.
- Copying multiple source tables into a destination table is not supported by the Google Cloud console.
- When copying multiple source tables to a destination table using the API, bq command-line tool, or the client libraries, all source tables must have identical schemas, including any partitioning or clustering.
Certain table schema updates, such as dropping or renaming columns, can cause tables to have apparently identical schemas but different internal representations. This might cause a table copy job to fail with the errorMaximum limit on diverging physical schemas reached. In this case, you can use theCREATE TABLE LIKE statementto ensure that your source table's schema matches the destination table's schema exactly. - The time that BigQuery takes to copy tables might vary significantly across different runs because the underlying storage is managed dynamically.
- You can't copy and append a source table to a destination table that has more columns than the source table, and the additional columns havedefault values. Instead, you can run
INSERT destination_table SELECT * FROM source_tableto copy over the data. - If the copy operation overwrites an existing table, then the table-level access for the existing table is maintained. Tags from the source table aren't copied to the overwritten table, while tags on the existing table are retained. However, when you copy tables across regions, tags on the existing table are removed.
- If the copy operation creates a new table, then the table-level access for the new table is determined by the access policies of the dataset in which the new table is created. Additionally, tags are copied from the source table to the new table.
- When you copy multiple source tables to a destination table, all source tables must have identical tags.
Required roles
To perform the tasks in this document, you need the following permissions.
Roles to copy tables and partitions
To get the permissions that you need to copy tables and partitions, ask your administrator to grant you theData Editor (roles/bigquery.dataEditor) IAM role on the source and destination datasets. For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to copy tables and partitions. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to copy tables and partitions:
bigquery.tables.getDataon the source and destination datasetsbigquery.tables.geton the source and destination datasetsbigquery.tables.createon the destination datasetbigquery.tables.updateon the destination dataset
You might also be able to get these permissions with custom roles or other predefined roles.
Permission to run a copy job
To get the permission that you need to run a copy job, ask your administrator to grant you theJob User (roles/bigquery.jobUser) IAM role on the source and destination datasets. For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains thebigquery.jobs.create permission, which is required to run a copy job.
You might also be able to get this permission with custom roles or other predefined roles.
Copy a single source table
You can copy a single table in the following ways:
- Using the Google Cloud console.
- Using the bq command-line tool's
bq cpcommand. - Using a data definition language (DDL)
CREATE TABLE COPYstatement. - Calling the jobs.insertAPI method, configuring a
copyjob, and specifying thesourceTableproperty. - Using the client libraries.
The Google Cloud console and the CREATE TABLE COPY statement support only one source table and one destination table in a copy job. To copy multiple source filesto a destination table, you must use the bq command-line tool or the API.
To copy a single source table:
Console
- In the left pane, click Explorer:

- In the Explorer pane, expand your project, click Datasets, and then select a dataset.
- Click Overview > Tables, and then select a table.
- In the details pane, click Copy.
- In the Copy table dialog, under Destination:
- For Project, choose the project that will store the copied table.
- For Dataset, select the dataset where you want to store the copied table. The source and destination datasets must be in the same location.
- For Table, enter a name for the new table. The name must be unique in the destination dataset. You can't overwrite an existing table in the destination dataset using the Google Cloud console. For more information about table name requirements, seeTable naming.
- Click Copy to start the copy job.
SQL
Use theCREATE TABLE COPY statementto copy a table namedtable1 to a new table named table1copy:
- In the Google Cloud console, go to the BigQuery page.
Go to BigQuery - In the query editor, enter the following statement:
CREATE TABLEmyproject.mydataset.table1copy
COPYmyproject.mydataset.table1; - Click Run.
For more information about how to run queries, see Run an interactive query.
bq
- In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. - Issue the
bq cpcommand. Optional flags can be used to control the write disposition of the destination table:-aor--append_tableappends the data from the source table to an existing table in the destination dataset.-for--forceoverwrites an existing table in the destination dataset and doesn't prompt you for confirmation.-nor--no_clobberreturns the following error message if the table exists in the destination dataset:Table 'project_id:dataset.table' already exists, skipping.If-nis not specified, the default behavior is to prompt you to choose whether to replace the destination table.--destination_kms_keyis the customer-managed Cloud KMS key used to encrypt the destination table.--destination_kms_keyis not demonstrated here. SeeProtecting data with Cloud Key Management Service keysfor more information.
If the source or destination dataset is in a project other than your default project, add the project ID to the dataset names in the following format:project_id:dataset.
(Optional) Supply the--locationflag and set the value to yourlocation.
bq --location=location cp \
-a -f -n \project_id:dataset.source_table\project_id:dataset.destination_table
Replace the following:location: the name of your location. The--locationflag is optional. For example, if you are using BigQuery in the Tokyo region, you can set the flag's value toasia-northeast1. You can set a default value for the location using the.bigqueryrc file.project_id: your project ID.dataset: the name of the source or destination dataset.source_table: the table you're copying.destination_table: the name of the table in the destination dataset.
Examples:
To copy themydataset.mytabletable to themydataset2.mytable2table, enter the following command. Both datasets are in your default project.
bq cp mydataset.mytable mydataset2.mytable2
To copy themydataset.mytabletable and to overwrite a destination table with the same name, enter the following command. The source dataset is in your default project. The destination dataset is in themyotherprojectproject. The-fshortcut is used to overwrite the destination table without a prompt.
bq cp -f \
mydataset.mytable \
myotherproject:myotherdataset.mytable
To copy themydataset.mytabletable and to return an error if the destination dataset contains a table with the same name, enter the following command. The source dataset is in your default project. The destination dataset is in themyotherprojectproject. The-nshortcut is used to prevent overwriting a table with the same name.
bq cp -n \
mydataset.mytable \
myotherproject:myotherdataset.mytable
To copy themydataset.mytabletable and to append the data to a destination table with the same name, enter the following command. The source dataset is in your default project. The destination dataset is in themyotherprojectproject. The- ashortcut is used to append to the destination table.
bq cp -a mydataset.mytable myotherproject:myotherdataset.mytable
API
You can copy an existing table through the API by calling thebigquery.jobs.insertmethod, and configuring a copy job. Specify your location in the location property in the jobReference section of thejob resource.
You must specify the following values in your job configuration:
"copy": { "sourceTable": { // Required "projectId": string, // Required "datasetId": string, // Required "tableId": string // Required }, "destinationTable": { // Required "projectId": string, // Required "datasetId": string, // Required "tableId": string // Required }, "createDisposition": string, // Optional "writeDisposition": string, // Optional },
Where sourceTable provides information about the table to be copied, destinationTable provides information about the new table, createDisposition specifies whether to create the table if it doesn't exist, and writeDisposition specifies whether to overwrite or append to an existing table.
C#
Before trying this sample, follow the C# setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery C# API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Go
Before trying this sample, follow the Go setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Go API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
Before trying this sample, follow the Java setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Java API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
Before trying this sample, follow the Node.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Node.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
PHP
Before trying this sample, follow the PHP setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery PHP API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
Before trying this sample, follow the Python setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Python API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Copy multiple source tables
You can copy multiple source tables to a destination table in the following ways:
- Using the bq command-line tool's
bq cpcommand. - Calling the jobs.insertmethod, configuring a
copyjob, and specifying thesourceTablesproperty. - Using the client libraries.
All source tables must have identical schemas and tags, and only one destination table is allowed.
Source tables must be specified as a comma-separated list. You can't use wildcards when you copy multiple source tables.
To copy multiple source tables, select one of the following choices:
bq
- In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. - Issue the
bq cpcommand and include multiple source tables as a comma-separated list. Optional flags can be used to control the write disposition of the destination table:-aor--append_tableappends the data from the source tables to an existing table in the destination dataset.-for--forceoverwrites an existing destination table in the destination dataset and doesn't prompt you for confirmation.-nor--no_clobberreturns the following error message if the table exists in the destination dataset:Table 'project_id:dataset.table' already exists, skipping.If-nis not specified, the default behavior is to prompt you to choose whether to replace the destination table.--destination_kms_keyis the customer-managed Cloud Key Management Service key used to encrypt the destination table.--destination_kms_keyis not demonstrated here. SeeProtecting data with Cloud Key Management Service keysfor more information.
If the source or destination dataset is in a project other than your default project, add the project ID to the dataset names in the following format:project_id:dataset.
(Optional) Supply the--locationflag and set the value to yourlocation.
bq --location=location cp \
-a -f -n \project_id:dataset.source_table,project_id:dataset.source_table\project_id:dataset.destination_table
Replace the following:location: the name of your location. The--locationflag is optional. For example, if you are using BigQuery in the Tokyo region, you can set the flag's value toasia-northeast1. You can set a default value for the location using the.bigqueryrc file.project_id: your project ID.dataset: the name of the source or destination dataset.source_table: the table that you're copying.destination_table: the name of the table in the destination dataset.
Examples:
To copy themydataset.mytabletable and themydataset.mytable2table tomydataset2.tablecopytable, enter the following command . All datasets are in your default project.
bq cp \
mydataset.mytable,mydataset.mytable2 \
mydataset2.tablecopy
To copy themydataset.mytabletable and themydataset.mytable2table tomyotherdataset.mytabletable and to overwrite a destination table with the same name, enter the following command. The destination dataset is in themyotherprojectproject, not your default project. The-fshortcut is used to overwrite the destination table without a prompt.
bq cp -f \
mydataset.mytable,mydataset.mytable2 \
myotherproject:myotherdataset.mytable
To copy themyproject:mydataset.mytabletable and themyproject:mydataset.mytable2table and to return an error if the destination dataset contains a table with the same name, enter the following command. The destination dataset is in themyotherprojectproject. The-nshortcut is used to prevent overwriting a table with the same name.
bq cp -n \
myproject:mydataset.mytable,myproject:mydataset.mytable2 \
myotherproject:myotherdataset.mytable
To copy themydataset.mytabletable and themydataset.mytable2table and to append the data to a destination table with the same name, enter the following command. The source dataset is in your default project. The destination dataset is in themyotherprojectproject. The-ashortcut is used to append to the destination table.
bq cp -a \
mydataset.mytable,mydataset.mytable2 \
myotherproject:myotherdataset.mytable
API
To copy multiple tables using the API, call thejobs.insertmethod, configure a table copy job, and specify the sourceTablesproperty.
Specify your region in the location property in thejobReference section of the job resource.
Go
Before trying this sample, follow the Go setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Go API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
Before trying this sample, follow the Java setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Java API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
Before trying this sample, follow the Node.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Node.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
Before trying this sample, follow the Python setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Python API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Copy tables across regions
You can copy a table, table snapshot, ortable clone from one BigQuery region or multi-region to another. This includes any tables that have customer-managed Cloud KMS (CMEK) applied.
Copying a table across regions incurs additional data transfer charges according to BigQuery pricing. Additional charges are incurred even if you cancel the cross-region table copy job before it has been completed.
To copy a table across regions, select one of the following options:
bq
In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.Run the bq cp command:
bq cp
-f -nSOURCE_PROJECT:SOURCE_DATASET.SOURCE_TABLEDESTINATION_PROJECT:DESTINATION_DATASET.DESTINATION_TABLE
Replace the following:
SOURCE_PROJECT: source project ID. If the source dataset is in a project other than your default project, add the project ID to the source dataset name.DESTINATION_PROJECT: destination project ID. If the destination dataset is in a project other than your default project, add the project ID to the destination dataset name.SOURCE_DATASET: the name of the source dataset.DESTINATION_DATASET: the name of the destination dataset.SOURCE_TABLE: the table that you are copying.DESTINATION_TABLE: the name of the table in the destination dataset.
The following example is a command that copies the mydataset_us.mytable table from the us multi-region to the mydataset_eu.mytable2 table in the eu multi-region. Both datasets are in the default project.
bq cp --sync=false mydataset_us.mytable mydataset_eu.mytable2
To copy a table across regions into a CMEK-enabled destination dataset, you must enable CMEK on the table with a key from the table's region. The CMEK on the table doesn't have to be the same CMEK in use by the destination dataset. The following example copies a CMEK-enabled table to a destination dataset using the bq cp command.
bq cp source-project-id:source-dataset-id.source-table-id destination-project-id:destination-dataset-id.destination-table-id
Conversely, to copy a CMEK-enabled table across regions into a destination dataset, you can enable CMEK on the destination dataset with a key from the destination dataset's region. You can also use the destination_kms_keys flag in the bq cp command, as shown in the following example:
bq cp --destination_kms_key=projects/project_id/locations/eu/keyRings/eu_key/cryptoKeys/eu_region mydataset_us.mytable mydataset_eu.mytable2
API
To copy a table across regions using the API, call thejobs.insertmethod and configure a table copy job.
Specify your region in the location property in thejobReference section of the job resource.
C#
Before trying this sample, follow the C# setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery C# API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Go
Before trying this sample, follow the Go setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Go API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
Before trying this sample, follow the Java setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Java API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
Before trying this sample, follow the Node.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Node.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
PHP
Before trying this sample, follow the PHP setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery PHP API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
Before trying this sample, follow the Python setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Python API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Limitations
Copying a table across regions is subject to the following limitations:
- You can't copy a table using the Google Cloud console or the TABLE COPY DDLstatement.
- You can't copy a table if there are any policy tags on the source table.
- You can't copy a table if the source table is larger than 20 physical TiB. See get information about tables for the source table physical size. Additionally, copying source tables that are larger than 1 physical TiB across regions may need multiple retries to successfully copy them.
- You can't copy IAM policies associated with the tables. You can apply the same policies to the destination after the copy is completed.
- If the copy operation overwrites an existing table, tags on the existing table are removed.
- You can't copy multiple source tables into a single destination table.
- You can't copy tables in append mode. If you use
write_emptymode, the destination table must not exist. - Time travel information is not copied to the destination region.
- When you copy a table clone or snapshot to a new region, a full copy of the table is created. This incurs additional storage costs.
- Expiration time from the source table is copied to the destination table.
View current quota usage
You can view your current usage of query, load, extract, or copy jobs by running an INFORMATION_SCHEMA query to view metadata about the jobs ran over a specified time period. You can compare your current usage against the quota limit to determine your quota usage for a particular type of job. The following example query uses theINFORMATION_SCHEMA.JOBS view to list the number of query, load, extract, and copy jobs by project:
SELECT
sum(case when job_type="QUERY" then 1 else 0 end) as QRY_CNT,
sum(case when job_type="LOAD" then 1 else 0 end) as LOAD_CNT,
sum(case when job_type="EXTRACT" then 1 else 0 end) as EXT_CNT,
sum(case when job_type="COPY" then 1 else 0 end) as CPY_CNT
FROM region-REGION_NAME.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE date(creation_time)= CURRENT_DATE()
Maximum number of copy jobs per day per project quota errors
BigQuery returns this error when the number of copy jobs running in a project has exceeded the daily limit. To learn more about the limit for copy jobs per day, seeCopy jobs.
Error message
Your project exceeded quota for copies per project
Diagnosis
If you'd like to gather more data about where the copy jobs are coming from, you can try the following:
- If your copy jobs are located in a single or only a few regions, you can try querying the INFORMATION_SCHEMA.JOBStable for specific regions. For example:
SELECT
creation_time, job_id, user_email, destination_table.project_id, destination_table.dataset_id, destination_table.table_id
FROMPROJECT_ID.region-REGION_NAME.INFORMATION_SCHEMA.JOBS
WHERE
creation_time BETWEEN TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 2 DAY) AND CURRENT_TIMESTAMP()
AND job_type = "COPY"
order by creation_time DESC
You can also adjust the time interval depending on the time range you're interested in. - To see all copy jobs in all regions, you can use the following filter in Cloud Logging:
resource.type="bigquery_resource"
protoPayload.methodName="jobservice.insert"
protoPayload.serviceData.jobInsertRequest.resource.jobConfiguration.tableCopy:*
Resolution
- If the goal of the frequent copy operations is to create a snapshot of data, consider using table snapshotsinstead. Table snapshots are a cheaper and faster alternative to copying full tables.
- You can request a quota increase by contactingsupport orsales. It might take several days to review and process the request. We recommend stating the priority, use case, and the project ID in the request.
Delete tables
You can delete a table in the following ways:
- Using the Google Cloud console.
- Using a data definition language (DDL)
DROP TABLEstatement. - Using the bq command-line tool
bq rmcommand. - Calling the tables.deleteAPI method.
- Using the client libraries.
To delete all of the tables in the dataset,delete the dataset.
When you delete a table, any data in the table is also deleted. To automatically delete tables after a specified period of time, set thedefault table expirationfor the dataset or set the expiration time when you create the table.
Deleting a table also deletes any permissions associated with this table. When you recreate a deleted table, you must also manually reconfigure any access permissionspreviously associated with it.
Required roles
To get the permissions that you need to delete a table, ask your administrator to grant you theData Editor (roles/bigquery.dataEditor) IAM role on the dataset. For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to delete a table. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to delete a table:
bigquery.tables.deletebigquery.tables.get
You might also be able to get these permissions with custom roles or other predefined roles.
Delete a table
To delete a table:
Console
- In the left pane, click Explorer:

- In the Explorer pane, expand your project, click Datasets, and then select a dataset.
- Click Overview > Tables, and then select a table.
- In the details pane, click Delete.
- Type
"delete"in the dialog, then click Delete to confirm.
SQL
Use theDROP TABLE statement. The following example deletes a table named mytable:
- In the Google Cloud console, go to the BigQuery page.
Go to BigQuery - In the query editor, enter the following statement:
DROP TABLE mydataset.mytable; - Click Run.
For more information about how to run queries, see Run an interactive query.
bq
- In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. - Use the
bq rmcommand with the--tableflag (or-tshortcut) to delete a table. When you use the bq command-line tool to remove a table, you must confirm the action. You can use the--forceflag (or-fshortcut) to skip confirmation.
If the table is in a dataset in a project other than your default project, add the project ID to the dataset name in the following format:project_id:dataset.
bq rm \
-f \
-t \
project_id:dataset.table
Replace the following:project_id: your project IDdataset: the name of the dataset that contains the tabletable: the name of the table that you're deleting
Examples:
To delete themytabletable from themydatasetdataset, enter the following command. Themydatasetdataset is in your default project.
bq rm -t mydataset.mytable
To delete themytabletable from themydatasetdataset, enter the following command. Themydatasetdataset is in themyotherprojectproject, not your default project.
bq rm -t myotherproject:mydataset.mytable
To delete themytabletable from themydatasetdataset, enter the following command. Themydatasetdataset is in your default project. The command uses the-fshortcut to bypass confirmation.
bq rm -f -t mydataset.mytable
API
Call the tables.deleteAPI method and specify the table to delete using the tableId parameter.
C#
Before trying this sample, follow the C# setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery C# API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Go
Before trying this sample, follow the Go setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Go API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
Before trying this sample, follow the Java setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Java API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
Before trying this sample, follow the Node.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Node.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
PHP
Before trying this sample, follow the PHP setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery PHP API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
Before trying this sample, follow the Python setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Python API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Ruby
Before trying this sample, follow the Ruby setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQuery Ruby API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Troubleshoot deleted tables
There are three main reasons for a deleted table: manual table deletion, expiration, and dataset deletion.
Table deletion
Check Cloud Audit Logs for a google.cloud.bigquery.v2.TableService.DeleteTable event. To view deleted tables, select one of the following options:
Console
- In the Google Cloud console, go to the Logs Explorer page.
Go to Logs Explorer - In the Filter section, use the following Cloud Logging Filter and Run Query,
resource.type="bigquery_dataset"
protoPayload.methodName="google.cloud.bigquery.v2.TableService.DeleteTable"
protoPayload.resourceName="projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID" bq
- In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. - Use the
gcloud logging readcommand with the following filters:
gcloud logging read '
resource.type="bigquery_dataset"
protoPayload.methodName="google.cloud.bigquery.v2.TableService.DeleteTable"
protoPayload.resourceName=~"projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID"
'
Replace the following:PROJECT_ID: your project IDDATASET_ID: the name of the dataset that contains the tableTABLE_ID: the name of the table that was deleted
Table expiration
Tables can be created with an expiration time. Once this time is reached, BigQuery automatically deletes the table. To view deleted tables, select one of the following options:
Console
- In the Google Cloud console, go to the Logs Explorer page.
Go to Logs Explorer - In the Filter section, use the following Cloud Logging Filter and click Run Query.
protoPayload.methodName="InternalTableExpired"
protoPayload.resourceName="projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID" bq
- In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. - Use the
gcloud logging readcommand with the following filters:
gcloud logging read '
protoPayload.methodName="InternalTableExpired"
protoPayload.resourceName=~"projects/PROJECT_ID/datasets/DATASET_ID/tables/TABLE_ID"
'
Replace the following:PROJECT_ID: your project IDDATASET_ID: the name of the dataset that contains the tableTABLE_ID: the name of the table that was deleted
You can query the INFORMATION_SCHEMA.TABLE_OPTIONS view to check the expiration_timestamp column for existing tables.
Dataset deletion
If the dataset containing the table was deleted, the table will also be deleted. To view deleted tables, select one of the following options:
Console
- In the Google Cloud console, go to the Logs Explorer page.
Go to Logs Explorer - In the Filter section, use the following Cloud Logging Filter and Run Query.
resource.type="bigquery_dataset"
protoPayload.methodName="google.cloud.bigquery.v2.DatasetService.DeleteDataset"
protoPayload.resourceName="projects/PROJECT_ID/datasets/DATASET_ID" bq
- In the Google Cloud console, activate Cloud Shell.
Activate Cloud Shell
At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize. - Use the
gcloud logging readcommand with the following filters:
gcloud logging read '
resource.type="bigquery_dataset"
protoPayload.methodName="google.cloud.bigquery.v2.DatasetService.DeleteDataset"
protoPayload.resourceName=~"projects/PROJECT_ID/datasets/DATASET_ID"
'
Replace the following:PROJECT_ID: your project IDDATASET_ID: the name of the dataset that contains the table
Restore deleted tables
To learn how to restore or undelete deleted tables, seeRestore deleted tables.
Table security
To control access to tables in BigQuery, seeControl access to resources with IAM.
What's next
- For more information about creating and using tables, seeCreating and using tables.
- For more information about handling data, see Working With table data.
- For more information about specifying table schemas, see Specifying a schema.
- For more information about modifying table schemas, seeModifying table schemas.
- For more information about datasets, see Introduction to datasets.
- For more information about views, see Introduction to views.
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.
Last updated 2026-06-18 UTC.