Reputation: 71
I have a bigquery table with schema as :
CREATE TABLE `abc`
(
col2 STRING,
col1 DATE,
col3 STRING,
);
and after creating and loading months worth of data in it, I realised I want the DDL to look like,
CREATE TABLE `abc`
(
col1 DATE,
col2 STRING,
col3 STRING,
);
I want this change because the upstream ETL code expects it in this way.
Is there a way to achieve this?
PS: drop and create the table isn't an option as it has important data.
Thanks :)
Upvotes: 2
Views: 15170
Reputation: 2612
When you make the select you can pass the order you want for your columns.
Instead of selecting it like SELECT * FROM ...
just do it as SELECT col1, col2, col3 FROM ...
Upvotes: 1
Reputation: 678
You won't miss any data. Try this.
create or replace table <SCHEMA.NEW_TABLE_NAME> as
select col1,col2,col3 from <SCHEMA.OLD_TABLE_NAME>;
Upvotes: 12