1
0
Fork 0
mirror of https://github.com/imjasonh/gcloud-help synced 2026-07-09 02:55:19 +00:00
gcloud-help/gcloud/beta/sql/instances/execute-sql

75 lines
2.8 KiB
Text
Raw Normal View History

2025-09-24 11:08:57 +00:00
NAME
gcloud beta sql instances execute-sql - executes a statement on a Cloud SQL
instance
SYNOPSIS
gcloud beta sql instances execute-sql INSTANCE --sql=SQL
[--database=DATABASE, -d DATABASE]
[--partial_result_mode=PARTIAL_RESULT_MODE] [--row_limit=ROW_LIMIT]
[GCLOUD_WIDE_FLAG ...]
DESCRIPTION
(BETA) Executes a statement on a Cloud SQL instance. It will use the
credentials of the specified Google Cloud account to connect to the
2026-03-26 12:11:21 +00:00
instance, so an IAM user with the same name must exist in the instance.
WARNING: The requests and responses might transit through intermediate
locations between your client and the location of the target instance.
2025-09-24 11:08:57 +00:00
EXAMPLES
To execute a statement on a Cloud SQL instance, run:
2026-03-26 12:11:21 +00:00
$ gcloud beta sql instances execute-sql my-instance-name \
2025-09-24 11:08:57 +00:00
--sql="ALTER TABLE employees RENAME TO personnel;" \
2026-03-26 12:11:21 +00:00
--database=my-db
2025-09-24 11:08:57 +00:00
POSITIONAL ARGUMENTS
INSTANCE
Cloud SQL instance ID.
REQUIRED FLAGS
--sql=SQL
SQL statement(s) to execute. It supports multiple statements as well.
When it starts with the character '@', the rest should be a filepath to
2026-03-26 12:11:21 +00:00
read the SQL statement(s) from. For example, --sql=@my_script.sql.
2025-09-24 11:08:57 +00:00
OPTIONAL FLAGS
--database=DATABASE, -d DATABASE
Database on which the statement is executed.
--partial_result_mode=PARTIAL_RESULT_MODE
2026-03-26 12:11:21 +00:00
Controls how the API responds when the SQL execution result is
2025-09-24 11:08:57 +00:00
incomplete due to size limit or other reasons. The default mode is to
2026-03-26 12:11:21 +00:00
return an error instead of returning a partial result.
2025-09-24 11:08:57 +00:00
PARTIAL_RESULT_MODE must be one of:
ALLOW_PARTIAL_RESULT
2026-03-26 12:11:21 +00:00
If the complete result is unavailable, returns a partial result,
marks the field <code>partial_result</code> to <code>true</code>,
and doesn't throw an error.
2025-09-24 11:08:57 +00:00
FAIL_PARTIAL_RESULT
2026-03-26 12:11:21 +00:00
If the complete result is unavailable, returns an error and doesn't
2025-09-24 11:08:57 +00:00
return the partial result.
PARTIAL_RESULT_MODE_UNSPECIFIED
2026-03-26 12:11:21 +00:00
Unspecified mode, effectively the same as
<code>FAIL_PARTIAL_RESULT</code>.
2025-09-24 11:08:57 +00:00
--row_limit=ROW_LIMIT
Maximum number of rows to return. The default is unlimited.
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
2026-03-26 12:11:21 +00:00
This command is currently in beta and might change without notice. These
variants are also available:
$ gcloud sql instances execute-sql
2025-09-24 11:08:57 +00:00
$ gcloud alpha sql instances execute-sql