Please enable JavaScript to view this site.

Altova DatabaseSpy 2020 Enterprise Edition

You can also generate SQL statements based on an existing table or column. In this step, we will generate a CREATE statement from the table tblZookeepers, edit the statement, and use it to create a new table tblEmployees.

 

 

To add a table by editing a CREATE statement generated from an existing table:

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

2.In the Online Browser, right-click the tblZookeepers table.

3.Select the menu option Show in new SQL Editor | Create from the context menu. An SQL Editor window appears, displaying the following SQL statement:

dbs_create_tbl_vets

4.Edit the statement as shown below to create tblEmployees. The parts of the statement that need to be changed are marked using underlined, italic text:

 

CREATE TABLE
   [ZooDB].[dbo].[tblEmployees] (
       [EmployeeID] int IDENTITY (1, 1) NOT NULL,
       [FirstName] varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
       [LastName] varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
       [Address] varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
       [City] varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
       [State] varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
       [Telephone] varchar (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
       [DOB] datetime NOT NULL,
       CONSTRAINT [PK_Employee] PRIMARY KEY ([EmployeeID]) ) ;

 

5.Click the Execute ic_execute-sql button or press F5.In the Online Browser, right-click the ZooDB database and select Refresh from the context menu, or click the Refresh ic_refresh-datasource button.

The newly inserted table, tblEmployees, is displayed along with the tables that you created earlier.

© 2019 Altova GmbH