Importing Data from TXT Files

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Tutorials > "ZooDB" Database > Inserting Data into the Database >

Importing Data from TXT Files

DatabaseSpy provides an import function which allows you to insert data provided in text files into a database. Example text files for the zoo database are included in the tutorial folder of your DatabaseSpy installation. How to import data from XML files will be explained in the next step of this tutorial.

 

In this step, you will import data from the tblZookeepers.txt file into the database table tblZookepers.

 

 

To import data from text files into the database:

1.Click the Import ic_import button in the Tools toolbar, or select the menu option Tools | Import data to the database..., or press Ctrl+I.
2.Click the CSV button on the left side of the dialog box.
3.In the Selection tab, click ic_browse next to the Path, and select the tblZookeepers.txt file from the \Altova\DatabaseSpy2019\DatabaseSpyExamples\Tutorial sub-folder of the Documents folder.
4.Under Database Generation Options, select Update existing tables.
5.Under Import Mode, select Generate SQL in SQL Editor.
6.In the Preview group box, click the Apply Options button. This displays table data in the Preview window. To view the table definition, choose the Show Definition radio button.
7.Optionally, click inside the "Target Table Name" column to change the target table name.
8.Click the ZookID table icon ic_include-col until it changes to the symbol for a column not to be imported ic_exclude-col. The column header allows you to define the fields key type, and also if it should be included during the import process. We will not import the ZookID column since this is an identity column and the primary key will be generated automatically during import.

 

At this stage, if you followed all the steps above, the import options must be as shown below:

dbs_import_csv

9.Click the Generate SQL button. This creates an SQL script which can be executed to complete the import process. Click Generate SQL in the message box to view the script in the SQL Editor.
10.Click the Execute ic_execute-sql button or press F5.

 

You can now view the imported data as follows:

 

In the Online Browser, right-click the tblZookeepers table and select Retrieve data | All rows from the context menu (alternatively, press Ctrl+Alt+R).

sql_retrieve-zookeepers


© 2019 Altova GmbH