Create and Alter Tables

 

The Create and Alter Table Assistant offers a convenient way to create new tables with all the features your database server offers. Create Table Assistant recognizes your database server type on startup and displays the values accepted by your database server.

Create Tables

 

Start the Create Table Assistant

Open the connection to your database server with any of the main interface windows (SQL Viewer, SQL Console, Database Navigator or Database Quick Access). The Database Information Panel displays your connected database type and some Common Tasks.

Click the "Create Table" button to open the Create Table Assistant for your selected database connection.

The Create Table Assistant automatically displays the options available for your database server. Enter a new table name and specify in which Catalog and/or Schema your new table should be saved. If you do not specify a Catalog or Schema the new table is usually created within the standard Catalog/Schema specified with the New Connection Assistant for this connection.

Click "Next >>" to continue with the assistant.

     
 

Add your columns to the table definition

An empty table definition is displayed. Click "+" on the right side to add a new column to your table. The new column is added to the column list and a drawer is displayed with the settings for this column. You can change the column name, data type and settings with the drawer or in the column list.

You can add as many columns as your database server supports per table (usually between 512 and 4096) by clicking "+". To remove a column click "-". "CC" copies a column with the settings you've already made.

Available column options (drawer):


Name   Specify your column name here. Usually characters a-z, all numbers and underscore (_) is allowed for column names by every database server. Special characters (like international characters) can be used by some database servers but are not recognized by all servers and are not part of ANSI SQL. Most database server allow column names to be 14-32 characters long.
     
Data Type   The Data Type selection displays the data types available with the selected database server. See your database vendors documentation for more information on available data types and how they work.
     
Size  

Additional value to specify the maximum size/length of some data types. You must specify the maximum length for CHAR, VARCHAR, NUMBER and NUMERIC data types.

DATE, TIMESTAMP, BLOB, INTEGER and other data types usually do not support a manual size restriction. Leave the Size field empty for these data types.

     
Scale  

Specify the scale for NUMBER and NUMERIC data types.

To store the number 99999.99 you must specify at least a size of 7 (7 digits without dot) with a scale of 2.

     
NULL   NULL means that a field does not necessarily contain a value. If you select NOT NULL a new record can only be added when this column contains a value.
     
Default Value   If you create a new record and do not specify a value for this column the default value is inserted into the database.
     
Primary Key   This specifies that this column is the primary key for this table which uniquely identifies each record. Primary keys are very important and every table should have one. Without primary keys your records cannot be uniquely identified for DELETE and UPDATE operations.
     
Auto Increment   This option is only available with MySQL. Makes this column auto increment, which means the value in this column is automatically and uniquely generated by the database server for each new record. Usually this option is used with primary keys to generate a unique id for each record in the table.
     
Unsigned   Special option for numeric columns if you do not want to store signed values.
     
Foreign Key  

The Foreign Key Constraint defines a reference to a second table/column for the current column.

The database server checks for each new record if the new value for this column is already available in the specified reference table/column. If the value is not listed in the referenced table/column your new record is declined. Please keep in mind that most database servers can only reference primary key columns (this means the reference column you specify here must be the primary key for the reference table).

For more information on foreign keys and referential integrity see your database vendors documentation.


Click "Next >>" to continue with the assistant.

     
 

Review and run the SQL command

The generate SQL command is displayed so you can make manual adjustments. Click "Finish" to execute the command and create the table.

On success a sheet is displayed which allows you to save your generated SQL command to create the table or close the assistant.

On error a description is displayed with the Message Viewer.

The table list in Database Quick Access and Database Navigator is not automatically reloaded after you create a new table. If you want to see your new table do this manually with the corner view menu of the Database Navigator or through de-selecting and re-selecting your database with Database Quick Access.

 

Alter Tables

 

Select the table you want to modify

Open the Database Navigator and select the table you want to modify. Start the Alter Table Assistant with the Corner menu from the Content list.

     
 

Edit your table definition

The Alter Table Assistant reads your current table definition and presents it like the Create Table Assistant. For more information on how to modify the definition see the description above.