- NAME
-
- gcloud alpha spanner databases execute-sql - executes a SQL query against a Cloud Spanner database
- SYNOPSIS
-
-
gcloud alpha spanner databases execute-sql
(DATABASE
:--instance
=INSTANCE
)--sql
=SQL
[--database-role
=DATABASE_ROLE
] [--enable-partitioned-dml
] [--priority
=PRIORITY
] [--query-mode
=QUERY_MODE
; default="NORMAL"] [--timeout
=TIMEOUT
; default="10m"] [--read-timestamp
=TIMESTAMP
|--strong
] [GCLOUD_WIDE_FLAG …
]
-
- DESCRIPTION
-
(ALPHA)
Executes a SQL query against a Cloud Spanner database. - EXAMPLES
-
To execute a SQL SELECT statement against example-database under
example-instance, run:
gcloud alpha spanner databases execute-sql example-database --instance=example-instance --sql='SELECT * FROM MyTable WHERE MyKey = 1'
- POSITIONAL ARGUMENTS
-
-
Database resource - The Cloud Spanner database to execute the SQL query against.
The arguments in this group can be used to specify the attributes of this
resource. (NOTE) Some attributes are not given arguments in this group but can
be set in other ways.
To set the
project
attribute:-
provide the argument
database
on the command line with a fully specified name; -
provide the argument
--project
on the command line; -
set the property
core/project
.
This must be specified.
DATABASE
-
ID of the database or fully qualified identifier for the database.
To set the
database
attribute:-
provide the argument
database
on the command line.
This positional argument must be specified if any of the other arguments in this group are specified.
-
provide the argument
--instance
=INSTANCE
-
The Cloud Spanner instance for the database.
To set the
instance
attribute:-
provide the argument
database
on the command line with a fully specified name; -
provide the argument
--instance
on the command line; -
set the property
spanner/instance
.
-
provide the argument
-
provide the argument
-
Database resource - The Cloud Spanner database to execute the SQL query against.
The arguments in this group can be used to specify the attributes of this
resource. (NOTE) Some attributes are not given arguments in this group but can
be set in other ways.
- REQUIRED FLAGS
-
--sql
=SQL
- The SQL query to issue to the database. Cloud Spanner SQL is described at https://cloud.google.com/spanner/docs/query-syntax
- OPTIONAL FLAGS
-
--database-role
=DATABASE_ROLE
- Database role user assumes while accessing the database.
--enable-partitioned-dml
- Execute DML statement using Partitioned DML
--priority
=PRIORITY
-
The priority for the execute SQL request.
PRIORITY
must be one of:high
,low
,medium
,unspecified
. --query-mode
=QUERY_MODE
; default="NORMAL"-
Mode in which the query must be processed.
QUERY_MODE
must be one of:NORMAL
- Returns only the query result, without any information about the query plan.
PLAN
- Returns only the query plan, without any result rows or execution statistics information.
PROFILE
- Returns both the query plan and the execution statistics along with the result rows.
--timeout
=TIMEOUT
; default="10m"- Maximum time to wait for the SQL query to complete. See $ gcloud topic datetimes for information on duration formats.
-
Read-only query timestamp bound. The default is --strong. See https://cloud.google.com/spanner/docs/timestamp-bounds.
At most one of these can be specified:
--read-timestamp
=TIMESTAMP
- Perform a query at the given timestamp.
--strong
- Perform a strong query.
- GCLOUD WIDE FLAGS
-
These flags are available to all commands:
--access-token-file
,--account
,--billing-project
,--configuration
,--flags-file
,--flatten
,--format
,--help
,--impersonate-service-account
,--log-http
,--project
,--quiet
,--trace-token
,--user-output-enabled
,--verbosity
.Run
$ gcloud help
for details. - NOTES
-
This command is currently in alpha and might change without notice. If this
command fails with API permission errors despite specifying the correct project,
you might be trying to access an API with an invitation-only early access
allowlist. These variants are also available:
gcloud spanner databases execute-sql
gcloud beta spanner databases execute-sql
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-02-06 UTC.