Inserting data to a table

BigQuery allows the insertion of individual rows into a table. For this example, we will start by creating a blank campaign impression table and then use a query to insert individual rows into a table:

  1. Find the testdataset dataset. If you do not have this dataset, see step 1 and step 2 in the Creating a Table section.
  2. Click on the plus sign next to the testdataset in the left-hand-side navigation. You will be prompted to select your table options. Under Source Data, select Create empty table.
  3. Give your table a name: testtable.
  4. Under Schema, name the first column date, a type of DATE, and leave the Mode as NULLABLE.
  5. Click on Add Field, give the second column a name of campaign, leave the type as STRING, and leave the Mode as NULLABLE.
  6. Click on Add Field. Give the third column a name of impressions, a type of INTEGER, and leave the Mode as NULLABLE.
  7. Then click on Create Table. A blank table with a schema will be created.
  8. Once created, enter the following query into the query dialog and click on Run Query:
#standardSQL
INSERT `testdataset.testtable` (`date`, `campaign`, `impressions` )
VALUES ('2017-01-01', 'summerdeals', 25000)
  1. This query adds a row with the three values listed after the VALUES section of the table. You should end up with the table output shown as follows:

  2. The previous step added one row; however, multiple rows can be added at once by adding another row of data delimited by a comma:
#standardSQL
INSERT `testdataset.testtable` (`date`, `campaign`, `impressions` )
VALUES ('2017-01-01', 'summersplash', 10000), ('2017-01-01', 'cybermondayad', 18000)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.93.64