Adding Tables to the Database

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

Home >  Tutorials > "ZooDB" Database >

Adding Tables to the Database

In the previous section, you have created a database project and added a connection to a database to it. However, this database does not contain any tables yet. In DatabaseSpy, you can add tables with only a few mouse clicks.

 

Objective

In this section of the tutorial, you will learn how to use SQL scripts and the Design Editor to create the tables that make up the zoo database. Specifically, you will learn how to do the following:

 

Open and execute an SQL file that is supplied in the tutorial folder
Add a table using the Design Editor
Generate and modify a CREATE statement
Create relationships between the tables

 

Commands used in this section

Icon

Command name

Description


Open

This command is located in the context menu that opens when you right-click an SQL file in the SQL folder of the Project window. Alternatively, you can also double-click the SQL file to open the SQL script in an SQL Editor window.

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_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.

ic_refresh-datasource

Refresh

This command is available in the Online Browser as a button, or as an option in the context menu that opens when you right-click a database. Use this command to refresh the database and display new or changed database objects in the Online Browser.


Show in new SQL Editor | Create

This command is located in the context menu that opens when you right-click a table in the Online Browser. Click this command to generate a CREATE statement based on the selected table in a new SQL Editor window.

ic_new-design-editor

Design Editor

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

ic_create-new-table

New Table

This command is located in the Design Editor toolbar; alternatively, you can also choose the menu option Design Editor | Create New Table or press Ctrl+T. Click this command to add a new table to an open Design Editor window.

ic_primary-key-constraints

Make Primary Key

This command is located in the context menu that appears when you right-click a table in a table design. Click this command to define the primary key for the table.

ic_foreign-key-constraint

Make Foreign Key

This command is located in the context menu that appears when you right-click a table in a table design. Click this command to define a new foreign key for the table.

ic_execute-sql

Execute Change Script

This command is located in the toolbar of the Database Structure Change Script window. Click this command to execute the recorded change script and to commit the changes to the database.


© 2019 Altova GmbH