ALTER TABLE

Created by: Lester Caine, Last modification: 20 Dec 2009 (09:11 GMT)

Created by: Jonathan Webley,Last modification on 05 Nov 2009 [17:39 UTC]by Daniel Luyo

ALTER TABLE is DDL used to to alter the structure of a table.

 

Examples

Add a column:

Firebird allows the addition of a column that is not null. ALTER TABLE should be followed by an UPDATE to populate the column.

Drop a column:

Rename a column:

Add a Primary Key

Add a Foreign Key:

Add a Check Constraint:

Drop a Constraint:

Firebird allows to change the order of a created columns. The position is 1 based.

Change a column position:

<span style="color: rgb(153, 51, 51); font-weight: bold;">ALTER</span> <span style="color: rgb(153, 51, 51); font-weight: bold;">TABLE</span> table1
   <span style="color: rgb(153, 51, 51); font-weight: bold;">ALTER</span> column1 POSITION <span style="color: rgb(204, 102, 204);">3</span>;