Creating or Modifying a Field from GUI
To add a field to a table, open that table, switch to the Fields page of the Table window, and click Add Field button. To modify an existing field, click Edit Field button. Note: If Edit Field button is inactive or invisible, such a function is not supported for this table or database type.
When adding or editing the field, specify the field name and type, choose other needed options, and click OK:
Notes
- Different database types have different set of field attributes.
Creating or Modifying Field Options
Field name | Specify a name for the field (when adding the field). |
Data type | Specify the data type for the field (if your database is not SQL-based database). |
SQL data type | Specify the SQL data type for the field (if your database is SQL-based database). |
Size / Precision | Specify the field size (for text compatible and some other field types like BLOB etc.) or field precision (for numeric fields). |
Scale | Specify the field scale for fields to hold floating-point numbers. This is the number of digits allowed after the decimal point. |
Default value | Specify default value for the field. |
Required | Specify either the field is required (i.e. does not allow NULL values). |
Description | Specify the field description (for databases which support this). |
Creating or Modifying a Field by SQL
Alternatively, you can create or modify fields by SQL means (except a few types of databases which does not support this).
For example, the next SQL command adds a new text field to a table (check the correct syntax for your database):
ALTER TABLE clients ADD middle_name VARCHAR(30)
This command sets the default value for a column in Firebird database:
ALTER TABLE clients ALTER COLUMN added SET DEFAULT current_date
And this command changes the column type in PostgreSQL database:
ALTER TABLE clients ALTER COLUMN middle_name TYPE TEXT
In some databases, you should type and execute a separate command to add a column comment (if you need this and the database supports this).
Please read your database documentation to learn the correct syntax and possible options.
See also