Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

Overview

Description

You can modify the structure of a table by using the ALTER statement. You can perform operations on the target table such as adding/deleting columns, creating/deleting indexes, and type casting existing columns as well as changing table names, column names and constraints. TABLE and CLASS are used interchangeably VIEW and VCLASS, and COLUMN and ATTRIBUTE as well.

You can also change the initial value of AUTO_INCREMENT.

Syntax

ALTER [ <class_type> ] <table_name> <alter_clause> ;

 

<class_type> ::= TABLE | CLASS | VCLASS | VIEW

 

<alter_clause> ::= ADD <alter_add> [ INHERIT <resolution_comma_list> ] | 

                   ADD { KEY | INDEX } <index_name> (<index_col_name>) |

                   ALTER [ COLUMN ] column_name SET DEFAULT <value_specifiation> |

                   DROP <alter_drop> [ INHERIT <resolution_comma_list> ] |

                   DROP { KEY | INDEXindex_name |

                   DROP FOREIGN KEY constraint_name |

                   DROP PRIMARY KEY |                   

                   RENAME <alter_rename> [ INHERIT <resolution_comma_list> ] |

                   CHANGE <alter_change> |

                   INHERIT <resolution_comma_list>

                   AUTO_INCREMENT = <initial_value>

 

<alter_add> ::= [ ATTRIBUTE | COLUMN ] [(]<class_element_comma_list>[)] [ FIRST | AFTER old_column_name ] |

                CLASS ATTRIBUTE <column_definition_comma_list> |

                CONSTRAINT < constraint_name > <column_constraint> ( column_name )|

                FILE <file_name_comma_list> |

                METHOD <method_definition_comma_list> |

                QUERY <select_statement> |

                SUPERCLASS <class_name_comma_list>

 

<alter_change> ::= FILE <file_path_name> AS <file_path_name> |

                   METHOD <method_definition_comma_list> |

                   QUERY [ <unsigned_integer_literal> ] <select_statement> |

                   <column_name> DEFAULT <value_specifiation>

 

<alter_drop> ::= [ ATTRIBUTE | COLUMN | METHOD ]

                 <column_name_comma_list> |

                 FILE <file_name_comma_list> |

                 QUERY [ <unsigned_integer_literal> ] |

                 SUPERCLASS <class_name_comma_list> |

                 CONSTRAINT <constraint_name>

 

<alter_rename> ::= [ ATTRIBUTE | COLUMN | METHOD ]

                   <old_column_name> AS <new_column_name> |

                   FUNCTION OF <column_name> AS <function_name>

                   FILE <file_path_name> AS <file_path_name>

 

<resolution> ::= { column_name | method_name } OF <superclass_name>

                 [ AS alias ]

 

<class_element> ::= <column_definition> | <table_constraint>

 

<column_constraint> ::= UNIQUE [ KEY ] | PRIMARY KEY | FOREIGN KEY

 

<index_col_name> ::=

column_name [(length)] [ ASC | DESC ]

Remark

The table name can be changed only by the table owner, DBA and DBA members. The other users must be granted to change the name by the owner or DBA (see Granting Authorization For details on authorization).