Cloud SQL stored procedures

This section describes stored procedures for Cloud SQL instances.

A stored procedure is SQL code that you can reuse.

To execute the stored procedure, you use the CALL command and replace the following variable:

  • procedure_name is the name of the stored procedure.
CALL procedure_name(parameters);
For more information, see the CALL statement reference page.

To create your own stored procedure, see the CREATE PROCEDURE and CREATE FUNCTION Statements.

mysql.addSecondaryIdxOnReplica

mysql.addSecondaryIdxOnReplica

Syntax

mysql.addSecondaryIdxOnReplica(IDXTYPE, IDXNAME, TABLENAME, IDXDEFINITION, IDXOPTION)

Description

Adds a secondary index on the database. This stored procedure is a wrapper for the CREATE INDEX DDL statement.

  • IDXTYPE – Type of index to create. For example, pass UNIQUE to create a unique index.
  • IDXNAME – Name of the index.
  • TABLENAME – Name of the table in the format of schema.name.
  • IDXDEFINITION – Definition of the index. Do not include outer parentheses.
  • IDXOPTION – Any additional options to pass on index creation. For example, in MySQL 8.0, an option could pass INVISIBLE for an invisible index.

mysql.dropSecondaryIdxOnReplica

Syntax

mysql.dropSecondaryIdxOnReplica(IDXNAME, TABLENAME, IDXOPTION)

Description

Drops a secondary index on the database. This stored procedure is a wrapper for the DROP INDEX DDL statement.

  • IDXNAME – Name of the index.
  • TABLENAME – Name of the table in the format of schema.name.
  • IDXOPTION – Any additional options to pass when dropping an index. For example, an algorithm option like INPLACE.

What's next