AlterTableBuilder
Defined in: js-api/src/entities/data-connection.ts:506
Single-action ALTER TABLE operations, obtained via DdlBuilder.alterTable.
Each method returns a DdlCommand for exactly one alteration (many databases
auto-commit DDL, so batching alterations would fake an atomicity that isn't there) —
run several alterations as sequential commands.
Constructors
Constructor
new AlterTableBuilder(
connectionId,_tableName,_schema?):AlterTableBuilder
Defined in: js-api/src/entities/data-connection.ts:507
Parameters
| Parameter | Type |
|---|---|
connectionId | string |
_tableName | string |
_schema? | string |
Returns
AlterTableBuilder
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
connectionId | readonly | string | js-api/src/entities/data-connection.ts:507 |
Methods
addColumn()
addColumn(
column):DdlCommand
Defined in: js-api/src/entities/data-connection.ts:512
Adds a column. A non-nullable column without a defaultValue is refused on a
populated table (required-without-default).
Parameters
| Parameter | Type |
|---|---|
column | DdlColumn |
Returns
changeType()
changeType(
columnName,newType,options?):DdlCommand
Defined in: js-api/src/entities/data-connection.ts:528
Changes the column's type to a dg type — destructive: requires confirmDestructive
when the column has non-null values (castability is not pre-verified; a failing cast
surfaces as the database's own error). MySQL and MSSQL restate the whole column on a
type change, so options.nullable is required there — the server refuses a MySQL/MSSQL
changeType without an explicit nullability.
Parameters
| Parameter | Type |
|---|---|
columnName | string |
newType | string |
options? | { nullable?: boolean; } |
options.nullable? | boolean |
Returns
dropColumn()
dropColumn(
columnName):DdlCommand
Defined in: js-api/src/entities/data-connection.ts:516
Drops a column — destructive: requires confirmDestructive when the column has
non-null values.
Parameters
| Parameter | Type |
|---|---|
columnName | string |
Returns
renameColumn()
renameColumn(
columnName,newName):DdlCommand
Defined in: js-api/src/entities/data-connection.ts:519
Renames a column (native RENAME COLUMN — non-destructive).
Parameters
| Parameter | Type |
|---|---|
columnName | string |
newName | string |
Returns
setNullable()
setNullable(
columnName,nullable):DdlCommand
Defined in: js-api/src/entities/data-connection.ts:536
Sets or drops NOT NULL. setNullable(col, false) with NULLs present is a hard
refusal (not-null-violation) — confirmation cannot help.
Parameters
| Parameter | Type |
|---|---|
columnName | string |
nullable | boolean |