Skip to main content

# AlterTable

Alters a table.

## Methods​

### selectDatabase()​

→ (`database` = String) → `this`

Selects a different database for this query.

Parameters

Parameter | Type | Description
--- | --- | ---
`database` | String | Name of the database to select

Returns

→ `this`

### structure()​

→ (`structure` = Structure) → `this`

The new desired structure for the table to get.

- Drops columns that are existing in the current table but not in the given structure
- Adds columns that are missing in the current table
- Modifies all other columns where at least one datatype is not matching

Parameters

Parameter | Type | Description
--- | --- | ---
`structure` | Structure | New structure definition for the table

Returns

→ `this`

### execute()​

`async` → () → any

Possible crash

structure() must always be given.

Executes the prepared query.

Returns

→ Instance.checkStructure() - Checks the structure afterwards and returns the check result