Reputation: 261
How could I create a BigQuery view via UI command or BQ command line?
I want to create a view like:
CREATE VIEW mydataset.myview AS
SELECT field1, field2
FROM mydataset.mytable
Upvotes: 11
Views: 45035
Reputation: 11
There're two ways of creating views in BQ.
Method 1: By Writing Queries
CREATE VIEW `projectid.datasetid.view_name` AS
SELECT FIELD1, FIELD2, ..
FROM `projectid.datasetid.table_name`
Note: If you run this view on the same project then you can omit projectid, you can mention datasetid.view_name. But if you run this view in other project then make sure to specify the projectid as well.
Method 2: Using GUI Step 1: Write your Select statement Step 2: Besides RUN button Save option will be there. Click on that dropdown menu and select "Save View" option to save your query as a view. Step 3: Provide name to your view Step 4: Check your dataset, a new view will get created.
Checkout this 1 hour BQ video, where you'll learn everything about BQ https://youtu.be/MYAfyPlVVak
Upvotes: 1
Reputation: 3653
You can use bq
command-line option:
bq query --use_legacy_sql=false 'CREATE OR REPLACE VIEW `project-name.dataset-name.view-name` AS SELECT * FROM `project-name.dataset-name.table-name`';
Upvotes: 3
Reputation: 7947
It looks like now is supported the views creation through standard sql. It requires specify project, dataset and table/view name. For example
create view `myproject.mydataset.myview` as select * from `myproject.mydataset.mytable`;
Upvotes: 9
Reputation: 3172
...
Upvotes: 19