AlterTable
Modifies an existing table by altering its structure.
Methods
selectDatabase()
→ (database = String) → this
Switches to a different database for this query.
Parameters
| Parameter | Type | Description |
|---|---|---|
database | String | The name of the database to select. |
Returns
→ this
structure()
→ (structure = Structure) → this
Defines the new table structure.
Behavrior
- Drops columns that exist in the current table but not in the new structure.
- Adds missing columns.
- Modifies columns where datatypes differ.
Parameters
| Parameter | Type | Description |
|---|---|---|
structure | Structure | The new structure definition. |
Returns
→ this
execute()
async → () → Instance.checkStructure()
Executes the prepared table alteration query.
Important
The structure() method must be called before executing, or the operation may fail.
Returns
→ Instance.checkStructure() - Performs a post-execution structure check and returns the result.