Skip Headers

# Adding Fields to a TableDefinition

Previous

Next

Use the `addField` method to add fields to the `TableDefinition`. To add the primary key field to the table, use the `addPrimaryKeyField` method rather than the `addField` method.

To maintain compatibility among different databases, the type parameter requires a Java class rather than a database field type. TopLink translates the Java class to the appropriate database field type at run time. For example, the `String` class translates to the `CHAR` type for dBase databases. However, if you are connecting to Sybase, the `String` class translates to `VARCHAR`. For more information, see "Schema Manager Java and Database Type Conversion".

The `addField` method can also be called with the `fieldSize` or `fieldSubSize` parameters for column types that require size and subsize to be specified.

Some databases require a subsize, but others do not. TopLink automatically provides the required information, as necessary.