instances

POST /v1/projects/{project}/instances/{instance}/executeSql

Changed on

Execute SQL statements.

Request

  • Base URL
    https://sqladmin.googleapis.com
  • Auth
    • OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/cloud-platform
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/cloud-platform
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/sqlservice.admin
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/sqlservice.admin

Path parameters

project, string required

Required. Project ID of the project that contains the instance.

instance, string required

Required. Database instance ID. This does not include the project ID.

Query parameters

$.xgafv, '1' | '2'

V1 error format.

access_token, string

OAuth access token.

alt, 'json' | 'media' | 'proto'

Data format for response.

callback, string

JSONP

fields, string

Selector specifying which fields to include in a partial response.

key, string

API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

oauth_token, string

OAuth 2.0 token for the current user.

prettyPrint, boolean

Returns response with indentations and line breaks.

quotaUser, string

Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

uploadType, string

Legacy upload protocol for media (e.g. "media", "multipart").

upload_protocol, string

Upload protocol for media (e.g. "raw", "multipart").

location, string

Optional. Region of the Cloud SQL instance.

Request body

ExecuteSqlPayload required

The request payload used to execute SQL statements.

application, string

Optional. Specifies the name of the application that is making the request. This field is used for telemetry. Only alphanumeric characters, dashes, and underscores are allowed. The maximum length is 32 characters.

autoIamAuthn, boolean

Optional. When set to true, the API caller identity associated with the request is used for database authentication. The API caller must be an IAM user in the database.

database, string

Optional. Name of the database on which the statement will be executed. For Postgres and SQL Server it's required, for MySQL it's optional.

partialResultMode, 'PARTIAL_RESULT_MODE_UNSPECIFIED' | 'FAIL_PARTIAL_RESULT' | 'ALLOW_PARTIAL_RESULT'

Optional. Controls how the API should respond when the SQL execution result is incomplete due to the size limit or another error. The default mode is to throw an error.

passwordSecretVersion, string

Optional. The resource name of the Secret Manager secret holding the password for the user to log into the database. The secret should be created using the regional endpoint (for API) or from the Regional Secrets page (for UI), and stored in the same region as the Cloud SQL instance. The expected resource name format is projects/{project}/locations/{location}/secrets/{secret}/versions/{secret_version}. Used together with the user field. The secret resource name will not be stored.

rowLimit, string int64

Optional. The maximum number of rows returned per SQL statement.

sqlStatement, string

Required. SQL statements to run on the database. It can be a single statement or a sequence of statements separated by semicolons.

user, string

Optional. The name of an existing database user to connect to the database. When auto_iam_authn is set to true, this field is ignored and the API caller's IAM user is used.

Response

Successful response

SqlInstancesExecuteSqlResponse required
messages, Message[]

A list of notices and warnings generated during query execution. For PostgreSQL, this includes all notices and warnings. For MySQL, this includes warnings generated by the last executed statement. To retrieve all warnings for a multi-statement query, SHOW WARNINGS must be executed after each statement.

metadata, Metadata

The additional metadata information regarding the execution of the SQL statements.

results, QueryResult[]

The list of results after executing all the SQL statements.

status, Status

The Status type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by gRPC. Each Status message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the API Design Guide.

Changes

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/sqlservice.admin was removed from the endpoint's security scheme Oauth2

    1 more change in this revision