gcloud beta sql instances execute-sql
Stay organized with collections
Save and categorize content based on your preferences.
- NAME
-
- gcloud beta sql instances execute-sql - executes a statement on a Cloud SQL instance
- SYNOPSIS
-
-
gcloud beta sql instances execute-sqlINSTANCE--sql=SQL[--database=DATABASE,-dDATABASE] [--partial-result-mode=PARTIAL_RESULT_MODE] [--password-secret-version=PASSWORD_SECRET_VERSION] [--row-limit=ROW_LIMIT] [--user=USER] [GCLOUD_WIDE_FLAG …]
-
- DESCRIPTION
-
(BETA)Executes a statement on a Cloud SQL instance. Before executing statements, follow Cloud SQL Data API's instructions to configure your database user and permissions. Note: The requests and responses might transit through intermediate locations between your client and the location of the target instance. - EXAMPLES
-
To execute a statement on a Cloud SQL instance using IAM database
authentication, run:
gcloudbetasqlinstancesexecute-sqlmy-instance-name--sql="ALTER TABLE employees RENAME TO personnel;"--database=my-dbTo execute a statement on a Cloud SQL instance using password authentication, run:
gcloudbetasqlinstancesexecute-sqlmy-instance-name--sql="ALTER TABLE employees RENAME TO personnel;"--database=my-db--user=my-user--password-secret-version=projects/my-project/locations/secret-location/secrets/my-secret/versions/latest - 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 read the SQL statement(s) from. For example, --sql=@my_script.sql.
- OPTIONAL FLAGS
-
--database=DATABASE,-dDATABASE- Database on which the statement is executed.
--partial-result-mode=PARTIAL_RESULT_MODE-
Controls how the API responds when the SQL execution result is incomplete due to
size limit or other reasons. The default mode is to return an error instead of
returning a partial result.
PARTIAL_RESULT_MODEmust be one of:ALLOW_PARTIAL_RESULT- 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.
FAIL_PARTIAL_RESULT- If the complete result is unavailable, returns an error and doesn't return the partial result.
PARTIAL_RESULT_MODE_UNSPECIFIED- Unspecified mode, effectively the same as <code>FAIL_PARTIAL_RESULT</code>.
--password-secret-version=PASSWORD_SECRET_VERSION- The resource name of the Secret Manager secret holding the password for the database user. The secret should be created using the regional endpoint and stored in the same region as the Cloud SQL instance. The expected resource name format is <code>projects/{project}/locations/{location}/secrets/{secret}/versions/{secret_version}</code>. Used together with <code>--user</code>. If not specified, IAM database authentication is used.
--row-limit=ROW_LIMIT- Maximum number of rows to return. The default is unlimited.
--user=USER- The database user to authenticate as. Used together with <code>--password-secret-version</code>. If not specified, IAM database authentication is used.
- 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 helpfor details. - NOTES
-
This command is currently in beta and might change without notice. These
variants are also available:
gcloudsqlinstancesexecute-sqlgcloudalphasqlinstancesexecute-sql