# `zModifyField_Proc` (procedure)


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sColumnName` | `varchar(100)` |
| 2 | IN | `sTableName` | `varchar(100)` |
| 3 | IN | `sType` | `varchar(100)` |
| 4 | IN | `sDefault` | `varchar(100)` |
| 5 | IN | `sIsNull` | `varchar(100)` |
| 6 | IN | `sComment` | `varchar(255)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `zModifyField_Proc`'`._

## Narrative

**Business context:** Maintenance / migration helper. Twin of `zAddField_Proc`: idempotent column-modifier that re-types an existing column (`MODIFY COLUMN`), used by Flyway scripts and upgrade SQLs to evolve a column's type / default / null-ability / comment without failing when the column is already absent.

**What it does:** `SELECT DATABASE() INTO sTableSchema`, lower-cases `sType`. Guards with `IF EXISTS (SELECT * FROM information_schema.COLUMNS WHERE COLUMN_NAME=sColumnName AND TABLE_SCHEMA=sTableSchema AND TABLE_NAME=sTableName)`. When `sDefault` is `''` picks a type-appropriate default (`''`, `0`, `0.000000`, `b'0'`, `now()`); when non-empty formats per type (varchar quoted, int/decimal literal, bit as `b'<val>'`, datetime literal). Builds `ALTER TABLE \`<tbl>\` MODIFY COLUMN \`<col>\` <type> <default> <isnull> <comment>` and runs it through `PREPARE`/`EXECUTE`. No `salsalesorderslave` carve-out (unlike `zAddField_Proc`).

**Invocation:** No DB-routine caller in the live catalog. Used by Flyway / upgrade scripts under `xly-src/script/标版/upgrade/` (e.g. `20230210_消息、工作流、定时 模块_20230210.sql`, `20220105-2751-保存、删除调过程/zAddFieldProc.sql`, `script/标版/20210323/zAddFieldScript.sql` / `zAddFieldProc.sql`). Fires from the same upgrade execution paths as `zAddField_Proc` whenever a column needs reshaping.
