Skip to main content

tables

Creates, updates, deletes, gets or lists a tables resource.

Overview

Nametables
TypeResource
Idgoogle.bigquery.tables

Fields

NameDatatypeDescription
idstringOutput only. An opaque ID uniquely identifying the table.
descriptionstringOptional. A user-friendly description of this table.
biglakeConfigurationobjectConfiguration for BigLake managed tables.
cloneDefinitionobjectInformation about base table and clone time of a table clone.
clusteringobjectConfigures table clustering.
creationTimestringOutput only. The time when this table was created, in milliseconds since the epoch.
defaultCollationstringOptional. Defines the default collation specification of new STRING fields in the table. During table creation or update, if a STRING field is added to this table without explicit collation specified, then the table inherits the table default collation. A change to this field affects only fields added afterwards, and does not alter the existing fields. The following values are supported: 'und:ci': undetermined locale, case insensitive. '': empty string. Default to case-sensitive behavior.
defaultRoundingModestringOptional. Defines the default rounding mode specification of new decimal fields (NUMERIC OR BIGNUMERIC) in the table. During table creation or update, if a decimal field is added to this table without an explicit rounding mode specified, then the field inherits the table default rounding mode. Changing this field doesn't affect existing fields.
encryptionConfigurationobjectConfiguration for Cloud KMS encryption settings.
etagstringOutput only. A hash of this resource.
expirationTimestringOptional. The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed. The defaultTableExpirationMs property of the encapsulating dataset can be used to set a default expirationTime on newly created tables.
externalCatalogTableOptionsobjectMetadata about open source compatible table. The fields contained in these options correspond to hive metastore's table level properties.
externalDataConfigurationobject
friendlyNamestringOptional. A descriptive name for this table.
kindstringThe type of resource ID.
labelsobjectThe labels associated with this table. You can use these to organize and group your tables. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key.
lastModifiedTimestringOutput only. The time when this table was last modified, in milliseconds since the epoch.
locationstringOutput only. The geographic location where the table resides. This value is inherited from the dataset.
materializedViewobjectDefinition and configuration of a materialized view.
materializedViewStatusobjectStatus of a materialized view. The last refresh timestamp status is omitted here, but is present in the MaterializedViewDefinition message.
maxStalenessstringOptional. The maximum staleness of data that could be returned when the table (or stale MV) is queried. Staleness encoded as a string encoding of sql IntervalValue type.
modelobject
numActiveLogicalBytesstringOutput only. Number of logical bytes that are less than 90 days old.
numActivePhysicalBytesstringOutput only. Number of physical bytes less than 90 days old. This data is not kept in real time, and might be delayed by a few seconds to a few minutes.
numBytesstringOutput only. The size of this table in logical bytes, excluding any data in the streaming buffer.
numCurrentPhysicalBytesstringOutput only. Number of physical bytes used by current live data storage. This data is not kept in real time, and might be delayed by a few seconds to a few minutes.
numLongTermBytesstringOutput only. The number of logical bytes in the table that are considered "long-term storage".
numLongTermLogicalBytesstringOutput only. Number of logical bytes that are more than 90 days old.
numLongTermPhysicalBytesstringOutput only. Number of physical bytes more than 90 days old. This data is not kept in real time, and might be delayed by a few seconds to a few minutes.
numPartitionsstringOutput only. The number of partitions present in the table or materialized view. This data is not kept in real time, and might be delayed by a few seconds to a few minutes.
numPhysicalBytesstringOutput only. The physical size of this table in bytes. This includes storage used for time travel.
numRowsstringOutput only. The number of rows of data in this table, excluding any data in the streaming buffer.
numTimeTravelPhysicalBytesstringOutput only. Number of physical bytes used by time travel storage (deleted or changed data). This data is not kept in real time, and might be delayed by a few seconds to a few minutes.
numTotalLogicalBytesstringOutput only. Total number of logical bytes in the table or materialized view.
numTotalPhysicalBytesstringOutput only. The physical size of this table in bytes. This also includes storage used for time travel. This data is not kept in real time, and might be delayed by a few seconds to a few minutes.
partitionDefinitionobjectThe partitioning information, which includes managed table, external table and metastore partitioned table partition information.
rangePartitioningobject
replicasarrayOptional. Output only. Table references of all replicas currently active on the table.
requirePartitionFilterbooleanOptional. If set to true, queries over this table require a partition filter that can be used for partition elimination to be specified.
resourceTagsobject[Optional] The tags associated with this table. Tag keys are globally unique. See additional information on tags. An object containing a list of "key": value pairs. The key is the namespaced friendly name of the tag key, e.g. "12345/environment" where 12345 is parent id. The value is the friendly short name of the tag value, e.g. "production".
restrictionsobject
schemaobjectSchema of a table
selfLinkstringOutput only. A URL that can be used to access this resource again.
snapshotDefinitionobjectInformation about base table and snapshot time of the snapshot.
streamingBufferobject
tableConstraintsobjectThe TableConstraints defines the primary key and foreign key.
tableReferenceobject
tableReplicationInfoobjectReplication info of a table created using AS REPLICA DDL like: CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv
timePartitioningobject
typestringOutput only. Describes the table type. The following values are supported: TABLE: A normal BigQuery table. VIEW: A virtual table defined by a SQL query. EXTERNAL: A table that references data stored in an external storage system, such as Google Cloud Storage. MATERIALIZED_VIEW: A precomputed view defined by a SQL query. * SNAPSHOT: An immutable BigQuery table that preserves the contents of a base table at a particular time. See additional information on table snapshots. The default value is TABLE.
viewobjectDescribes the definition of a logical view.

Methods

NameAccessible byRequired ParamsDescription
getSELECT+datasetId, +tableId, projectIdGets the specified table resource by table ID. This method does not return the data in the table, it only returns the table resource, which describes the structure of this table.
listSELECT+datasetId, projectIdLists all tables in the specified dataset. Requires the READER dataset role.
insertINSERT+datasetId, projectIdCreates a new, empty table in the dataset.
deleteDELETE+datasetId, +tableId, projectIdDeletes the table specified by tableId from the dataset. If the table contains data, all the data will be deleted.
patchUPDATE+datasetId, +tableId, projectIdUpdates information in an existing table. The update method replaces the entire table resource, whereas the patch method only replaces fields that are provided in the submitted table resource. This method supports RFC5789 patch semantics.
updateREPLACE+datasetId, +tableId, projectIdUpdates information in an existing table. The update method replaces the entire Table resource, whereas the patch method only replaces fields that are provided in the submitted Table resource.

SELECT examples

Lists all tables in the specified dataset. Requires the READER dataset role.

SELECT
id,
description,
biglakeConfiguration,
cloneDefinition,
clustering,
creationTime,
defaultCollation,
defaultRoundingMode,
encryptionConfiguration,
etag,
expirationTime,
externalCatalogTableOptions,
externalDataConfiguration,
friendlyName,
kind,
labels,
lastModifiedTime,
location,
materializedView,
materializedViewStatus,
maxStaleness,
model,
numActiveLogicalBytes,
numActivePhysicalBytes,
numBytes,
numCurrentPhysicalBytes,
numLongTermBytes,
numLongTermLogicalBytes,
numLongTermPhysicalBytes,
numPartitions,
numPhysicalBytes,
numRows,
numTimeTravelPhysicalBytes,
numTotalLogicalBytes,
numTotalPhysicalBytes,
partitionDefinition,
rangePartitioning,
replicas,
requirePartitionFilter,
resourceTags,
restrictions,
schema,
selfLink,
snapshotDefinition,
streamingBuffer,
tableConstraints,
tableReference,
tableReplicationInfo,
timePartitioning,
type,
view
FROM google.bigquery.tables
WHERE +datasetId = '{{ +datasetId }}'
AND projectId = '{{ projectId }}';

INSERT example

Use the following StackQL query and manifest file to create a new tables resource.

/*+ create */
INSERT INTO google.bigquery.tables (
+datasetId,
projectId,
biglakeConfiguration,
clustering,
defaultCollation,
defaultRoundingMode,
description,
encryptionConfiguration,
expirationTime,
externalCatalogTableOptions,
externalDataConfiguration,
friendlyName,
labels,
materializedView,
maxStaleness,
model,
partitionDefinition,
rangePartitioning,
requirePartitionFilter,
resourceTags,
schema,
tableConstraints,
tableReference,
tableReplicationInfo,
timePartitioning,
view
)
SELECT
'{{ +datasetId }}',
'{{ projectId }}',
'{{ biglakeConfiguration }}',
'{{ clustering }}',
'{{ defaultCollation }}',
'{{ defaultRoundingMode }}',
'{{ description }}',
'{{ encryptionConfiguration }}',
'{{ expirationTime }}',
'{{ externalCatalogTableOptions }}',
'{{ externalDataConfiguration }}',
'{{ friendlyName }}',
'{{ labels }}',
'{{ materializedView }}',
'{{ maxStaleness }}',
'{{ model }}',
'{{ partitionDefinition }}',
'{{ rangePartitioning }}',
{{ requirePartitionFilter }},
'{{ resourceTags }}',
'{{ schema }}',
'{{ tableConstraints }}',
'{{ tableReference }}',
'{{ tableReplicationInfo }}',
'{{ timePartitioning }}',
'{{ view }}'
;

UPDATE example

Updates a tables resource.

/*+ update */
UPDATE google.bigquery.tables
SET
biglakeConfiguration = '{{ biglakeConfiguration }}',
clustering = '{{ clustering }}',
defaultCollation = '{{ defaultCollation }}',
defaultRoundingMode = '{{ defaultRoundingMode }}',
description = '{{ description }}',
encryptionConfiguration = '{{ encryptionConfiguration }}',
expirationTime = '{{ expirationTime }}',
externalCatalogTableOptions = '{{ externalCatalogTableOptions }}',
externalDataConfiguration = '{{ externalDataConfiguration }}',
friendlyName = '{{ friendlyName }}',
labels = '{{ labels }}',
materializedView = '{{ materializedView }}',
maxStaleness = '{{ maxStaleness }}',
model = '{{ model }}',
partitionDefinition = '{{ partitionDefinition }}',
rangePartitioning = '{{ rangePartitioning }}',
requirePartitionFilter = true|false,
resourceTags = '{{ resourceTags }}',
schema = '{{ schema }}',
tableConstraints = '{{ tableConstraints }}',
tableReference = '{{ tableReference }}',
tableReplicationInfo = '{{ tableReplicationInfo }}',
timePartitioning = '{{ timePartitioning }}',
view = '{{ view }}'
WHERE
+datasetId = '{{ +datasetId }}'
AND +tableId = '{{ +tableId }}'
AND projectId = '{{ projectId }}';

REPLACE example

Replaces all fields in the specified tables resource.

/*+ update */
REPLACE google.bigquery.tables
SET
biglakeConfiguration = '{{ biglakeConfiguration }}',
clustering = '{{ clustering }}',
defaultCollation = '{{ defaultCollation }}',
defaultRoundingMode = '{{ defaultRoundingMode }}',
description = '{{ description }}',
encryptionConfiguration = '{{ encryptionConfiguration }}',
expirationTime = '{{ expirationTime }}',
externalCatalogTableOptions = '{{ externalCatalogTableOptions }}',
externalDataConfiguration = '{{ externalDataConfiguration }}',
friendlyName = '{{ friendlyName }}',
labels = '{{ labels }}',
materializedView = '{{ materializedView }}',
maxStaleness = '{{ maxStaleness }}',
model = '{{ model }}',
partitionDefinition = '{{ partitionDefinition }}',
rangePartitioning = '{{ rangePartitioning }}',
requirePartitionFilter = true|false,
resourceTags = '{{ resourceTags }}',
schema = '{{ schema }}',
tableConstraints = '{{ tableConstraints }}',
tableReference = '{{ tableReference }}',
tableReplicationInfo = '{{ tableReplicationInfo }}',
timePartitioning = '{{ timePartitioning }}',
view = '{{ view }}'
WHERE
+datasetId = '{{ +datasetId }}'
AND +tableId = '{{ +tableId }}'
AND projectId = '{{ projectId }}';

DELETE example

Deletes the specified tables resource.

/*+ delete */
DELETE FROM google.bigquery.tables
WHERE +datasetId = '{{ +datasetId }}'
AND +tableId = '{{ +tableId }}'
AND projectId = '{{ projectId }}';