Skip to main content

AlterTableBuilder

Defined in: js-api/src/entities/data-connection.ts:475

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:476

Parameters​

ParameterType
connectionIdstring
_tableNamestring
_schema?string

Returns​

AlterTableBuilder

Properties​

PropertyModifierTypeDefined in
connectionIdreadonlystringjs-api/src/entities/data-connection.ts:476

Methods​

addColumn()​

addColumn(column): DdlCommand

Defined in: js-api/src/entities/data-connection.ts:481

Adds a column. A non-nullable column without a defaultValue is refused on a populated table (required-without-default).

Parameters​

ParameterType
columnDdlColumn

Returns​

DdlCommand


changeType()​

changeType(columnName, newType, options?): DdlCommand

Defined in: js-api/src/entities/data-connection.ts:497

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​

ParameterType
columnNamestring
newTypestring
options?{ nullable?: boolean; }
options.nullable?boolean

Returns​

DdlCommand


dropColumn()​

dropColumn(columnName): DdlCommand

Defined in: js-api/src/entities/data-connection.ts:485

Drops a column — destructive: requires confirmDestructive when the column has non-null values.

Parameters​

ParameterType
columnNamestring

Returns​

DdlCommand


renameColumn()​

renameColumn(columnName, newName): DdlCommand

Defined in: js-api/src/entities/data-connection.ts:488

Renames a column (native RENAME COLUMN — non-destructive).

Parameters​

ParameterType
columnNamestring
newNamestring

Returns​

DdlCommand


setNullable()​

setNullable(columnName, nullable): DdlCommand

Defined in: js-api/src/entities/data-connection.ts:505

Sets or drops NOT NULL. setNullable(col, false) with NULLs present is a hard refusal (not-null-violation) — confirmation cannot help.

Parameters​

ParameterType
columnNamestring
nullableboolean

Returns​

DdlCommand