20 Sep 19 · npack · #Bigquery ·   Bookmark   ×

CREATE TABLE AS SELECT from another table in Bigquery (Copy DDL and Data)

To create a new table similar to another table copying both data and the structure,

CREATE TABLE mydataset.mynewtable
AS SELECT * FROM mydataset.myothertable;

To create a new partitioned table from a select query

CREATE TABLE mydataset.myclusteredtable
(
timestamp TIMESTAMP,
customer_id STRING,
transaction_amount NUMERIC
)
PARTITION BY DATE(timestamp)
CLUSTER BY
customer_id
OPTIONS (
partition_expiration_days=3,
description="a table clustered by customer_id"
)
AS SELECT * FROM mydataset.myothertable

npack

posted on 20 Sep 19

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds

Copied