This feature is covered by the of the Google Cloud Terms of Service. Pre-GA features might have limited support, and changes to pre-GA features might not be compatible with other pre-GA versions. For more information, see the . Show
PostgreSQL interface note: The preview release of fine-grained access control doesn't support the PostgreSQL interface for Cloud Spanner. PostgreSQL interface note: Spanner Vertex AI integration is not supported in PostgreSQL-dialect databases. Note: For the preview release of fine-grained access control, support will be provided directly by the engineering team instead of via support cases. You can engage with us at [email protected]. When fine-grained access control is generally available, support will be provided through the regular channels.Use Google Standard SQL's data definition language (DDL) to:
Notation
Reserved keywordsSome words have special meaning in the Google Standard SQL language and are reserved in its DDL. To use a reserved keyword as an identifier in your schema, enclose it in backticks ( 0). For the full list of reserved keywords in Google Standard SQL, see .For example: CREATE TABLE MyTable ( RowId INT64 NOT NULL, `Order` INT64 ) PRIMARY KEY (RowId); Naming conventionsThe following rules apply to database IDs.
The following rules apply to table, column, index, view, role, and constraint names.
Data typesThe following are the data types used in Google Standard SQL. ScalarsThe syntax for using a scalar type in DDL is: { BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+ An 6 must correspond to an integer from -9,223,372,036,854,775,808 (-263) to 9,223,372,036,854,775,807 (263 − 1). It can be specified with decimal or hexadecimal notation. The hexadecimal form requires a 7 prefix, with a lowercase 8.STRING 9 is a variable length Unicode character string. Its value must be a valid Unicode string. Length is required, and represents the maximum number of Unicode characters (not bytes) that can be stored in the field.Notes:
JSON 4 is a variable length Unicode character string representing a JSON object. The string must be UTF-8 encoded on receipt at the server. The maximum length of the JSON value is 2621440 characters.See Working with JSON and for details. BYTES 5 is a variable length binary string. Length is required, and represents the maximum number of bytes that can be stored in the field.Notes:
DATE
TIMESTAMP
ArraysThe syntax for using the 9 type in DDL is:ARRAY< scalar_type > Google Standard SQL supports arrays of scalars. The primary purpose of arrays is to store a collection of values in a space efficient way. Arrays are not designed to provide access to individual elements; to read or write a single element, you must read or write the entire array. If your application uses data structures like vectors or repeated fields, you can persist their state in a Google Standard SQL array. Here's an example of an alternate definition of 2 that uses multiple columns of 9 type:CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...; Notes:
DATABASE statementsCREATE DATABASEWhen creating a Google Standard SQL database, you must provide a { BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+0 statement, which defines the ID of the database: CREATE DATABASE database_id where database_id {a—z}[{a—z|0—9|_|-}+]{a—z|0—9} Parameters{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+1
ALTER DATABASEChanges the definition of a database. Syntax 0Description{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+2 changes the definition of an existing database. { BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+3
Parameters{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+1
{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+6
TABLE statementsCREATE TABLEDefines a new table. Syntax 1Description 3 defines a new table in the current database.ParametersCREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;3
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;4
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;5
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;6
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;8
5
CREATE DATABASE database_id where database_id {a—z}[{a—z|0—9|_|-}+]{a—z|0—9}3 CREATE DATABASE database_id where database_id {a—z}[{a—z|0—9|_|-}+]{a—z|0—9}4 CREATE DATABASE database_id where database_id {a—z}[{a—z|0—9|_|-}+]{a—z|0—9}5
02CREATE DATABASE database_id where database_id {a—z}[{a—z|0—9|_|-}+]{a—z|0—9}4 04
For examples on how to work with generated columns, see Creating and managing generated columns. 12CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;4 14
For more details, see Schema and data model. 16CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;3 18
For more details, see Schema and data model. 25 26
27CREATE DATABASE database_id where database_id {a—z}[{a—z|0—9|_|-}+]{a—z|0—9}4 CREATE DATABASE database_id where database_id {a—z}[{a—z|0—9|_|-}+]{a—z|0—9}5
37CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;4 39 40 41 42 43
For details, see Foreign keys. 46
48CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;6 50CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;8 52
ALTER TABLEChanges the definition of a table. Syntax 2Description 53 changes the definition of an existing table. 54
74
76 77
85 26
87
71
14CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;6 50CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;8 18
19
20CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;6 50CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;8 18
ParametersCREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;3
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;4
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;5
77
26
40
42
DROP TABLERemoves a table. Syntax 3DescriptionUse the 35 statement to remove a table from the database.
ParametersCREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;3
INDEX statementsCREATE INDEXUse the 39 statement to define secondary indexes.Syntax 4DescriptionSpanner automatically indexes the primary key columns of each table. You can use 39 to create secondary indexes for other columns. Adding a secondary index on a column makes it more efficient to look up data in that column. For more details, see secondary indexes.Note: Spanner has a hard size limit of 8 KB for the total size of a table key or an index key. To work around this limitation, you can create a stored generated column with expressions and an index column.Parameters 41
44
46
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;3
48
15
61
ALTER INDEXUse the 62 statement to add additional columns or remove stored columns from the secondary indexes.Syntax 5DescriptionAdd an additional column into an index or remove a column from an index. Parameters 46
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;4
DROP INDEXRemoves a secondary index. Syntax 6DescriptionUse the 65 statement to drop a secondary index.Parameters 46
VIEW statementsCREATE VIEW and CREATE OR REPLACE VIEWUse the 67 or 68 statement to define a view.Syntax 7Description 67 defines a new view in the current database. If a view named 70 exists, the 67 statement fails. 68 defines a new view in the current database. If a view named 70 exists, its definition is replaced.Parameters 74
75
AS 76
DROP VIEWRemoves a view. Syntax 8DescriptionUse the 77 statement to remove a view from the database.Parameters 74
ROLE statementsCREATE ROLEDefines a new database role. Syntax 9Description 79 defines a new database role for fine-grained access control. Database roles are collections of privileges. You can create only one role with this statement.Parameters 80
ExampleThis example creates the database role 83. 84DROP ROLEDrops a database role. Syntax 0Description 85 drops a database role. You can drop only one role with this statement.You can't drop a database role if it has any privileges granted to it. All privileges granted to a database role must be revoked before the role can be dropped. You can drop a database role whether or not it's granted to IAM principals. Dropping a role automatically revokes its membership in other roles and revokes the membership of its members. You can't drop system roles. Parameters 80
ExampleThis example drops the database role 83. 88GRANT and REVOKE statementsGRANTSyntax 1DescriptionFor fine-grained access control, grants privileges on one or more tables to database roles, or grants database roles to other database roles to create a database role hierarchy. When granting privileges on a table, optionally grants privileges on only a subset of table columns. ParametersCREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;3
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;4
80
Notes and restrictions
ExamplesThe following example grants 95 on the 96 table to the 97 role. Grantees of the 97 role can read all columns of 96. 00The next example grants 95 on a subset of columns of the 02 table to the 97 role. Grantees of the 97 role can read only the named columns. 05The next example mixes table-level and column-level grants. 83 can read all table columns, but can update only the 07 column. 08The next example makes column-level grants on two tables. Both tables must contain the 07 column. 10The next example grants 94 on a subset of columns of the 96 table. 13The next example grants the database role 14 to the roles 83 and 16. The 83 and 16 roles are members of 14 and inherit the privileges that were granted to 14. 21REVOKESyntax 2DescriptionFor fine-grained access control, revokes privileges on one or more tables from database roles, or revokes database roles from other database roles. When revoking privileges on a table, optionally revokes privileges on only a subset of table columns. ParametersCREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;3
CREATE TABLE Singers ( SingerId INT64, FeaturedSingerIds ARRAY<INT64>, SongNames ARRAY<STRING(MAX)> ) PRIMARY KEY (SingerId) ...;4
80
Notes and restrictions
ExamplesThe following example revokes 95 on the 96 table from the role 97. 29The next example revokes 95 on a subset of columns of the 02 table from the role 97. 33The next example shows revoking both table-level and column-level privileges in a single statement. 34The next example revokes column-level grants on two tables. Both tables must contain the 07 column. 36The next example revokes 94 on a subset of columns. 38The following example revokes the database role 14 from the 83 and 16 database roles. The 83 and 16 roles lose any privileges that they inherited from 14. 45STATISTICS statementsALTER STATISTICSChanges the definition of a query optimizer statistics package. Syntax 3Description 46 changes the definition of a query optimizer statistics package.{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+3
Parameters 48
{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+6
ANALYZEStart a new query optimizer statistics package construction. Syntax 4Description 53 starts a new query optimizer statistics package construction.MODEL statementsCREATE MODEL and CREATE OR REPLACE MODELUse the 54 or 55 statement to define an ML model.Note: The preview release of Spanner Vertex AI integration supports only classifier and regression ML models.Syntax 5Description 54 registers a reference to the Vertex AI ML model in the current database. If a model named 57 already exists, the 54 statement fails. 55 registers a reference to the Vertex AI ML model in the current database. If a model named 57 already exists, its definition is replaced. 61 registers a reference to the Vertex AI ML model in the current database. If a model named 57 already exists, the 61 statement does not have any effect.As soon as the model reference is registered in a database, it can be used from queries that use the ML.Predict function. Model registration doesn't result in copying a model from the Vertex AI to a database, but only in creation of a reference to this models' endpoint hosted in the Vertex AI. If the model's endpoint gets removed from the Vertex AI, Cloud Spanner queries referencing this model fail. Model endpoint access controlTo be able to access a registered Vertex AI model endpoint from Cloud Spanner, you need to grant access permission to Cloud Spanner's service agent account. For example, it can be done by granting the role to the 65 account, where 66 is the ID of the project that hosts your Cloud Spanner instance.If the Cloud Spanner service agent account doesn't exist for your project, create it by running the following command after replacing PROJECT with the project name: 67.Parameters 68
69
75 and 74 respectively. 80
ALTER MODELChanges the definition of a model. Note: The preview release of Spanner Vertex AI integration supports only classifier and regression ML models.Syntax 6Description 83 changes the definition of an existing table.{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | JSON | BYTES( length ) | DATE | TIMESTAMP } length: { int64_value | MAX } int64_value: { decimal_value | hex_value } decimal_value: [-]0—9+ hex_value: [-]0x{0—9|a—f|A—F}+3
Parameters 68
80
DROP MODELRemoves a model. Syntax 7DescriptionUse the 89 statement to remove a model definition from the database. Unless the 90 clause is specified, the statement fails if the model doesn't exist.After you delete a model definition, all SQL queries referencing the deleted model fail. Dropping a model definition does not affect the underlying the Vertex AI endpoint that this model is attached to. Which of the following claims would be the best solution to the pest problem based on the data in the graph?Which of the following claims would be the best solution to the pest problem, based on the data in the graph? Use of Integrated Pest Management techniques is the most successful method because the sources for food, water, and shelter for pests are disrupted, leading to a reduced number of pests in the area.
Which of the following is a limitation of using only the data in the table to complete an ecological?Which of the following is a limitation of using only the data in the table to complete an ecological footprint analysis of the different students? The footprint is a static analysis and does not include all environmental impacts of an individual.
Which of the following methods of agricultural irrigation results in the loss of the least amount of water?Drip irrigation is a very efficient way to irrigation crops and has the advantage of lower evaporation than other irrigation methods, it is the most common type of "microirrigation." Drip irrigation is one of the more advanced techniques being used today because, for certain crops, it is much more efficient than ...
Which of the following best defines aquaculture?Aquaculture is the breeding, rearing, and harvesting of fish, shellfish, algae, and other organisms in all types of water environments.
|