gcloud alpha sql instances execute-sql Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha sql instances execute-sql - executes a statement on a Cloud SQL instance
- SYNOPSIS
gcloud alpha sql instances execute-sqlINSTANCE--sql=SQL[--database=DATABASE,-dDATABASE][--partial_result_mode=PARTIAL_RESULT_MODE][--row_limit=ROW_LIMIT][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(ALPHA)Executes a statement on a Cloud SQL instance. It will usethe credentials of the specified Google Cloud account to connect to theinstance, so an IAM user with the same name must exist in the instance. Itdoesn't support DQL or DML statements yet. WARNING: The requests and responsesmight transit through intermediate locations between your client and thelocation of the target instance.- EXAMPLES
- To execute a statement on a Cloud SQL instance, run:
gcloudalphasqlinstancesexecute-sqlinstance-foo--sql="ALTER TABLE employees RENAME TO personnel;"--database=db1 - POSITIONAL ARGUMENTS
INSTANCE- Cloud SQL instance ID.
- REQUIRED FLAGS
--sql=SQL- SQL statement(s) to execute. It supports multiple statements as well. When itstarts with the character '@', the rest should be a filepath to read the SQLstatement(s) from.
- OPTIONAL FLAGS
--database=DATABASE,-dDATABASE- Database on which the statement is executed.
--partial_result_mode=PARTIAL_RESULT_MODE- Controls how the API should respond when the SQL execution result is incompletedue to size limit or other reasons. The default mode is to throw an errorinstead of returning the partial result.
PARTIAL_RESULT_MODEmust be one of:ALLOW_PARTIAL_RESULT- Return the partial result and mark the field partial_result to true if thecomplete result can't be returned. Don't throw an error.
FAIL_PARTIAL_RESULT- Throw an error if the complete result can't be returned. Don't return thepartial result.
PARTIAL_RESULT_MODE_UNSPECIFIED- Unspecified mode, effectively the same as
FAIL_PARTIAL_RESULT.
--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 helpfor details. - NOTES
- This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. This variant is also available:
gcloudbetasqlinstancesexecute-sql
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-24 UTC.