Database Reference
In-Depth Information
Repeated list of fields, or
columns, in the table.
schema.fields
object
array
string
Name of the field.
schema.fields.name
string
Type of the field. One of
{
INTEGER
,
FLOAT
,
BOOLEAN,
TIMESTAMP
,
STRING
, or
RECORD
}.
schema.fields.type
string
Field mode. One of
{
NULLABLE
,
REQUIRED
, or
REPEATED
}. Default is
NULLABLE
.
schema.fields.mode
Nested schema field records, of
the same type as
schema.fields
.
schema.fields.fields
object
array
number
Friendly name for the table.
Not unique.
friendlyName
string
Description of the table.
description
Tables.insert()
You can create a table via the
Tables.insert()
operation; although in
practice, most tables are created as a side effect of a job. For example, a Load
job can specify a create disposition of
CREATE_IF_NEEDED
, which means
the target table will be created if it doesn't already exist. One reason you
might want to create a table by hand is if you want to reserve the name
and make sure it is available for querying (that is, it wouldn't cause an
error) even before any data arrives. Alternatively, you might want to specify
an expiration time so that the table will be automatically deleted when it
expires.
Here is the output of using
curl
to create a simple table (after re-creating
the dataset first with
bq
):
$
bq mk -d scratch
$
TABLES_URL=${DATASETS_URL}/scratch/tables
$
SCHEMA="{'fields': [{'name':'foo', 'type':