Altova DatabaseSpy 2025 Enterprise Edition

Earlier in this tutorial, you added several SQL scripts to the ZooDBProject. The scripts contain SQL statements that either create the database structure or populate it with data. For example, the file tblAnimalTypes_data.sql contains all the INSERT statements that are necessary to add data to the tblAnimalTypes and tblAnimalCategories tables.

dbs_zoo_tutorial_08

Project window

As previously mentioned in Opening and Executing an SQL File, you can change the target data source for each script in the Properties window. This is typically necessary when your project contains multiple data sources and you must ensure that you are running the script against the correct database.

 

It is also possible to assign the target data source of multiple scripts simultaneously. For example, in the Project window illustrated above, notice that all the script files are in the SQL folder. By changing the folder's properties, you can assign the same target data source to all the scripts, as follows:

 

1.Open the "ZooDB" project created previously and double-click the dbs_ic_connected ZooDBConnect data source to connect to it.

2.Click the SQL folder in the Project window.

3.In the Properties window, select "ZooDBConnect" from the Data Source list.

dbs_zoo_tutorial_change_data_source

All the SQL files from the SQL folder should now have the same data source. Click any of the script files and observe the assigned data source in the Properties window.

 

Next, let's populate two of the database tables with data, by running a script:

 

In the Project window, right-click the file tblAnimalTypes_data.sql and select Execute SQL ic_execute-sql from the context menu. The file opens in an SQL Editor window and executes automatically.

 

The tables tblAnimalTypes and tblAnimalCategories should now be populated with data. To do a quick check as to whether the tables have been successfully populated with data, right-click the "User Tables" folder and select Row Count | Show/Update from the context menu.

tab_ob-row-count

© 2018-2024 Altova GmbH