In the previous section of the tutorial, you added the create_ZooDB_tables.sql script to your database project. This script can now be run to add tables to the zoo database. Note that any SQL script will be executed against the currently assigned data source, as shown below.
To add tables to a database by executing an SQL script:
1.Open the "ZooDB" project created previously and double-click the ZooDBConnect data source to connect to it.
2.In the Project window, double-click the create_ZooDB_tables.sql entry in the SQL folder. The script file opens in an SQL Editor window.
|Note:||A new SQL Editor window is automatically associated with the data source that is active in the Online Browser or Project Window. The active data source is displayed at all times in the Execution Target Bar. That is, all commands issued from SQL Editor will affect this particular data source only. If there are multiple data sources, the SQL Editor belongs to the one which was last clicked before you opened the SQL Editor. Any subsequent SQL Editor windows that you open will inherit the currently active data source.|
3.If necessary, assign a data source to the current script. When the script has no data source assigned, the "Unknown - Offline" status appears at the top of the SQL Editor window.
To assign a data source to the script, click the Offline hyperlink and, in the Properties window, select "ZooDBConnect" from the Data Source list.
The SQL script is now connected to the ZooDBConnect data source, and the execution buttons in the SQL Editor are active. Click the Save Project button in the Project window or press Ctrl+S to save this data source assignment in the project properties.
4.In the SQL Editor, click the Execute button or press F5.
If the script executed successfully, several new tables will have been added to the database:
You can view the tables by clicking the Online Browser tab, and expanding the folder structure as shown above.
After performing changes to the database, make sure to refresh the data displayed in the Online Browser. To do this, right-click on the name of the database, "ZooDB" in this example, and select Refresh from the context menu or click the Refresh button.