ALTER COLUMN ... SET DEFAULT Clause

Description

You can specify a new default value for a column that has no default value or modify the existing default value by using the ALTER COLUMNSET DEFAULT. You can use the CHANGE clause to change the default value of multiple columns with a single statement. For details, see the CHANGE Clause.

Syntax

ALTER [ TABLE | CLASS ] table_name ALTER [COLUMN] column_name SET DEFAULT value

Example

;schema a_tbl

 

=== <Help: Schema of a Class> ===

 

 

 <Class Name>

 

     a_tbl

 

 <Attributes>

 

     name                 CHARACTER VARYING(1073741823)

     phone                CHARACTER VARYING(13) DEFAULT '000-0000-0000'

     age                  INTEGER

     id                   INTEGER AUTO_INCREMENT  NOT NULL

 

 <Constraints>

 

     UNIQUE u_a_tbl_id ON a_tbl (id)

 

 

Current transaction has been committed.

 

 

ALTER TABLE a_tbl ALTER COLUMN name SET DEFAULT '';

ALTER TABLE a_tbl ALTER COLUMN phone SET DEFAULT '111-1111';

 

;schema a_tbl

 

=== <Help: Schema of a Class> ===

 

 

 <Class Name>

 

     a_tbl

 

 <Attributes>

 

     name                 CHARACTER VARYING(1073741823) DEFAULT ''

     phone                CHARACTER VARYING(13) DEFAULT '111-1111'

     age                  INTEGER

     id                   INTEGER AUTO_INCREMENT  NOT NULL

 

 <Constraints>

 

     UNIQUE u_a_tbl_id ON a_tbl (id)