ASA SQL User's Guide
Importing and Exporting Data
Exporting
In addition to the methods described below, you can also export a table by selecting all the data in a table and exporting the query results. For more information, see Exporting query results.
TipYou can export views just as you would export tables. |
To export a table (Command line)
At a command prompt, enter the following dbunload command and press Enter:
dbunload -c "dbn=asademo;uid=DBA;pwd=SQL" -t employee c:\temp
where -c
specifies the database connection parameters and -t
specifies the name of the table(s) you want to export. This dbunload command unloads the data from the sample database (assumed to be running on the default database server with the default database name) into a set of files in the c:\temp directory. A command file to rebuild the database from the data files is created with the default name reload.SQL in the current directory.
You can unload more than one table by separating the table names with a comma (,) delimiter.
To export a table (SQL)
Execute an UNLOAD TABLE statement. For example,
UNLOAD TABLE department TO 'dept.txt'
This statement unloads the department table from the sample database into the file dept.txt in the server's current working directory. If you are running against a network server, the command unloads the data into a file on the server machine, not the client machine. Also, the file name passes to the server as a string. Using escape backslash characters in the file name prevents misinterpretation if a directory of file name begins with an n (\n is a newline character) or any other special characters.
Each row of the table is output on a single line of the output file, and no column names are exported. The columns are separated, or delimited, by a comma. The delimiter character can be changed using the DELIMITED BY clause. The fields are not fixed-width fields. Only the characters in each entry are exported, not the full width of the column.
For more information about the UNLOAD TABLE statement syntax, see UNLOAD TABLE statement.