ALTER TABLE Statement (alter_table_statement)

An ALTER TABLE statement (alter_table_statement) changes the properties of a base table.

Syntax

<alter_table_statement> ::=
  ALTER TABLE <table_name> <
add_definition>
| ALTER TABLE <table_name> <
alter_definition>
| ALTER TABLE <table_name> <
column_change_definition>
| ALTER TABLE <table_name> <
drop_definition>
| ALTER TABLE <table_name> <
modify_definition>
| ALTER TABLE <table_name> <
referential_constraint_definition>
| ALTER TABLE <table_name> <
sample_definition>

Examples

SQL Tutorial, Tables, Primary Key, Constraints, Foreign Key Dependencies Between Tables

Explanation

If the name of the schema is not specified in the table name, the current schema is accepted/used. The table name must be the name of an existing base table. The table must not be a temporary base table. The current user must have the ALTER privilege for the specified table.

ADD definition

Defines additional table properties.

ALTER definition

Changes a CONSTRAINT or key definition.

COLUMN change definition

Changes column properties

DROP definition

Deletes table properties

MODIFY definition

Changes data types and column attributes

Referential CONSTRAINT definition

Defines a new referential constraint

SAMPLE definition

Defines a number of rows which the database system is to take into account when it determines table statistics (sample size).

You can exclude individual tables from an UPDATE STATISTICS run by setting a sample size of 0 for these tables.