Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Importing and Exporting Data » Importing data » Importing tables

Importing tables Next Page

Table structures for import


The structure of the source data does not need to match the structure of the destination table itself. For example, the column data types may be different or in a different order, or there may be extra values in the import data that do not match columns in the destination table.

Rearranging the table or data

If you know that the structure of the data you want to import does not match the structure of the destination table, you can:

Allowing columns to contain NULL values

If the file you are importing contains data for a subset of the columns in a table, or if the columns are in a different order, you can also use the LOAD TABLE statement DEFAULTS option to fill in the blanks and merge non-matching table structures.

For example, you can define a default value for the City column in the Employees table and then load new rows into the Employees table using a LOAD TABLE statement like this:

ALTER TABLE Employees
ALTER City DEFAULT 'Waterloo';
LOAD TABLE Employees (Surname, GivenName, EmployeeID, DepartmentID, StartDate)
FROM 'new_employees.txt'
DEFAULTS ON

Since a value is not provided for the City column, the default value is supplied. If DEFAULTS OFF had been specified, the City column would have been assigned the empty string instead.