Cloud SQL stored procedures Stay organized with collections Save and categorize content based on your preferences.
This section describes stored procedures for Cloud SQL instances.
A stored procedure contains SQL code that you can reuse.
You cannot drop or alter system stored procedures.To execute a stored procedure, you use theCALL command and replace thefollowing variable:
- procedure_name is the name of the stored procedure.
CALLprocedure_name(parameters);
To create a stored procedure, seeCREATE PROCEDURE and CREATE FUNCTION Statements.Cloud SQL doesn't support theCREATE FUNCTION statement. For more information,seeUnsupported MySQL features for Cloud SQL.
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 fortheCREATE 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 fortheDROP 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
- Learn how toadd and drop indexes on Cloud SQL read replicas.
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-12-15 UTC.