Alter Table Tool

The Alter Table Tool allows users to visually alter tables. The Alter Table Tool can generate and/or execute the SQL that corresponds to any table alterations specified by the user.

After selecting the database and/or schema name and table name, the Alter Table Tool displays a window showing the types of alterations available:

NOTE: Not all of the following are available for all databases.

Add Column - Adds a column to a table
Add Primary Key - Adds a primary key to a table
Add Foreign Key - Adds a foreign key to a table
Add Constraint - Adds a check constraint to a table
Change Column Type - Changes the data type of a column
Drop Column - Drops a column from a table
Drop Constraint - Drops a check constraint from a table
Drop Primary Key - Drops a primary key from a table
Drop Foreign Key - Drops a foreign key from a table
Rename Table - Renames a table
Rename Column - Renames a column

Listed below are some sample SQL statements generated by the Alter Table Tool. These examples are not databse independent. The database specific alter table tools provided by RazorSQL will generate the appropriate Alter Table command for the particular database.

The following command is used to rename a table:

ALTER TABLE public.department RENAME TO department_new

The following command is used to rename a column on a table.

ALTER TABLE public.department RENAME COLUMN dnumber TO dnumber_new

The following command adds a primary key to the table.

ALTER TABLE public.department ADD PRIMARY KEY (dname)

The following command adds a foreign key to the table.

ALTER TABLE sample.public.employee
ADD FOREIGN KEY (dno)
REFERENCES public.department(dnumber)

The following are links to information about the Alter Table tool for some of the databases supported by RazorSQL:

Access Alter Table
DB2 Alter Table
Derby Alter Table
Firebird Alter Table
FrontBase Alter Table
H2 Alter Table
HSQLDB Alter Table
Informix Alter Table
Ingres Alter Table
InterBase Alter Table
MySQL Alter Table
OpenBase Alter Table
Oracle Alter Table
PostgreSQL Alter Table
MS SQL Server Alter Table
SQLite Alter Table
SQL Anywhere Alter Table
Sybase Alter Table
Teradata Alter Table