Inserting Data into the Database

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

Home >  Tutorials > "ZooDB" Database >

Inserting Data into the Database

To insert data into the database, you can enter individual INSERT statements into an SQL Editor window or save them in an SQL file and execute all the statements together. More conveniently, DatabaseSpy also allows you to import data from TXT files and add new records in the Result window after executing a SELECT statement for editing.

 

Objective

In this section of the tutorial, you will learn how to insert data into the tables you have created in the previous section. Specifically, you will learn how to do the following:

 

Execute an SQL script that populates the zoo database with data
Import data provided in a TXT file
Import data provided in an XML file
Create a new SQL script and save it in the project
Add new records in the Result window of the SQL Editor

 

Commands used in this section

Icon

Command name

Description

ic_execute-sql

Execute SQL

This command is located in the context menu that opens when you right-click an SQL file in the SQL folder of the Properties window. Use this command to immediately execute the SQL statements contained in the file.


Row Count | Show/Update

This command is available in the context menu that opens when you right-click a table, view or its parent folder in the Online Browser. Click this command to display the number of rows for the selected table or view, or the number of rows for all tables or views, respectively, that are contained in the selected folder.

ic_import

Import

This command is located in the Tools toolbar; alternatively, you can also choose the menu option Tools | Import data to the database... or press Ctrl+I. Click this command to open the Import data to the database dialog box.

ic_execute-sql

Execute

This command is located in the toolbar of an SQL Editor window and in the SQL Editor menu. Click this command to execute the SQL in the SQL Editor window.


Retrieve data | All rows

This command is located in the context menu that opens when you right-click a table or column in the Online Browser; alternatively, you can also select the table and press Ctrl+Alt+R. Click this command to have all rows of data displayed in a Result tab.

ic_new-sql-editor

SQL Editor

This command is located in the Standard toolbar; alternatively, you can also choose the menu option File | New | SQL Editor or press Ctrl+N. Click this command to open a new SQL Editor window that is assigned to the active data source connection.

ic_save

Save

This command is located in the Standard toolbar; alternatively, you can also choose the menu option File | Save or press Ctrl+S. Click this command to save the active file.

ic_add_active_file

Add the Active File

This command is located in the toolbar of the Project window. Clicking this command adds the active file to the project under its corresponding folder.

ic_save_project

Save Project

This command is located in the toolbar of the Project window; alternatively, you can also choose the menu option File | Save Project As... or press Ctrl+S. Click this command to save an existing project under its project name or to specify a name and path for a new project, respectively.

ic_edit

Edit Data

This command is located in the context menu that opens when you right-click a table or column in the Online Browser; alternatively, you can also select the table and press Ctrl+Alt+E. Choose this command to generate an SQL SELECT statement that is automatically executed in the SQL Editor and switches the Result window into the Editing mode. This command works for all supported database kinds for both ADO and ODBC connections.

ic_add_line

Append a new row

This command is available as a button in the Result window toolbar. Click this button to add a new row to the result grid. Alternatively, you can also right-click anywhere in the result grid and choose Append a new row from the context menu. The Append a new row command is only available if the Result window is in the Editing mode.

ic_commit

Commit

This command is available as a button in the Result window toolbar. Click this button to commit the changes you have made in the result grid to the database. The Commit button is only visible if the Result window is in the Editing mode.


© 2019 Altova GmbH