Agrega un índice secundario a la base de datos. Este procedimiento almacenado es un wrapper para la declaración DDL CREATE INDEX.
IDXTYPE: Tipo de índice que se creará. Por ejemplo, pasa UNIQUE para crear un índice único.
IDXNAME: Nombre del índice.
TABLENAME: Nombre de la tabla en el formato de schema.name.
IDXDEFINITION: Definición del índice. No incluyas paréntesis externos.
IDXOPTION: Cualquier opción adicional para pasar la creación del índice. Por ejemplo, en MySQL 8.0, una opción podría pasar INVISIBLE para un índice invisible.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[],[],null,["# Cloud SQL stored procedures\n\n\u003cbr /\u003e\n\nMySQL \\| [PostgreSQL](/sql/docs/postgres/stored-procedures \"View this page for the PostgreSQL database engine\") \\| [SQL Server](/sql/docs/sqlserver/stored-procedures \"View this page for the SQL Server database engine\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis section describes stored procedures for Cloud SQL instances.\n\nA stored procedure contains SQL code that you can reuse.\n| You cannot drop or alter system stored procedures.\n\nTo execute a stored procedure, you use the `CALL` command and replace the\nfollowing variable:\n\n- \u003cvar translate=\"no\"\u003eprocedure_name\u003c/var\u003e is the name of the stored procedure.\n\n```sql\nCALL procedure_name(parameters);\n```\nFor more information, see the [CALL statement](https://dev.mysql.com/doc/refman/8.0/en/call.html) reference page.\n\n\u003cbr /\u003e\n\nTo create a stored procedure, see [CREATE PROCEDURE and CREATE FUNCTION Statements](https://dev.mysql.com/doc/refman/8.0/en/create-procedure.html).\nCloud SQL doesn't support the `CREATE FUNCTION` statement. For more information,\nsee [Unsupported MySQL features for Cloud SQL](/sql/docs/features#unsupported-statements).\n\n\n| **Note:** You cannot run some stored procedures because they require a `sysadmin` role, which isn't available in Cloud SQL.\n\n\u003cbr /\u003e\n\nmysql.addSecondaryIdxOnReplica\n------------------------------\n\n### mysql.addSecondaryIdxOnReplica\n\n**Syntax** \n\n```sql\nmysql.addSecondaryIdxOnReplica(IDXTYPE, IDXNAME, TABLENAME, IDXDEFINITION, IDXOPTION)\n```\n\n**Description**\n\nAdds a secondary index on the database. This stored procedure is a wrapper for\nthe [CREATE INDEX](https://dev.mysql.com/doc/refman/8.0/en/create-index.html) DDL statement.\n\n- \u003cvar translate=\"no\"\u003eIDXTYPE\u003c/var\u003e -- Type of index to create. For example, pass UNIQUE to create a unique index.\n- \u003cvar translate=\"no\"\u003eIDXNAME\u003c/var\u003e -- Name of the index.\n- \u003cvar translate=\"no\"\u003eTABLENAME\u003c/var\u003e -- Name of the table in the format of schema.name.\n- \u003cvar translate=\"no\"\u003eIDXDEFINITION\u003c/var\u003e -- Definition of the index. Do not include outer parentheses.\n- \u003cvar translate=\"no\"\u003eIDXOPTION\u003c/var\u003e -- Any additional options to pass on index creation. For example, in MySQL 8.0, an option could pass INVISIBLE for an invisible index.\n\n### mysql.dropSecondaryIdxOnReplica\n\n**Syntax** \n\n```sql\nmysql.dropSecondaryIdxOnReplica(IDXNAME, TABLENAME, IDXOPTION)\n```\n\n**Description**\n\nDrops a secondary index on the database. This stored procedure is a wrapper for\nthe [DROP INDEX](https://dev.mysql.com/doc/refman/8.0/en/drop-index.html) DDL statement.\n\n- \u003cvar translate=\"no\"\u003eIDXNAME\u003c/var\u003e -- Name of the index.\n- \u003cvar translate=\"no\"\u003eTABLENAME\u003c/var\u003e -- Name of the table in the format of schema.name.\n- \u003cvar translate=\"no\"\u003eIDXOPTION\u003c/var\u003e -- Any additional options to pass when dropping an index. For example, an algorithm option like INPLACE.\n\nWhat's next\n-----------\n\n- Learn how to [add and drop indexes on Cloud SQL read replicas](/sql/docs/mysql/replication/read-replica-indexes)."]]