Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
ALTER TABLE Command
Previous  Top  Next



ALTER TABLE allows you to change the structure of an existing table.

Syntax

ALTER TABLE [ MEMORY ] table_name alter_specification

where alter_specification is:

ADD ( [ [ IF NOT EXISTS ] column_definition ] [, ... ] [ index_definition ] [, ... ] )  
| MODIFY ( [ column_definition ] [, ... ] )  
| DROP ( [ column_name ] [, ... ] )  
| RENAME [ COLUMN ] old_column_name [ TO ] new_column_name  
| RENAME [ TABLE ] [ TO ] new_table_name  

Description

ALTER TABLE allows you to change the structure of an existing table. For example, you can add or delete columns, create indexes, change the type of existing columns, or rename columns or the table itself.

MEMORY
If MEMORY keyword is specified before the table_name then an in-memory table will be altered, not a disk one.  

table_name
The name of the table to be altered.  

ADD
Adds the new column(s) and index(es) using the same syntax as CREATE TABLE.  

IF NOT EXISTS
If this keyword is specified, the coulmn will be created, only if there is no existing column with the same name. If this keyword is not specified and the column already exists, an exception will be raised.  

MODIFY
Changes the column(s) settings such as data type, size, default value, etc..  

DROP
Deletes the specified column(s).  

RENAME COLUMN
Changes a name of a column to the new_column_name value.  

RENAME TABLE
Changes a name of a table to the new_table_name value.  

Example:

ALTER TABLE employee ADD (height Float);  

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 21, 2024