---
sidebar_position: 9
---

# AlterTable

Alters a table.

## Methods

### selectDatabase()
&rarr; (`database` = __String__) &rarr; `this`

Selects a different database for this query.

**Parameters**

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

**Returns**

&rarr; `this`

***

### structure()
&rarr; (`structure` = [Structure](./structure)) &rarr; `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](./structure) | New structure definition for the table |

**Returns**

&rarr; `this`

***

### execute()
`async` &rarr; () &rarr; __any__

:::warning Possible crash
[structure()](#structure) must always be given.
:::

Executes the prepared query.

**Returns**

&rarr; [Instance.checkStructure()](./instance#checkstructure) - Checks the structure afterwards and returns the check result

***