Generating and Editing a CREATE Statement

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

Home >  Tutorials > "ZooDB" Database > Adding Tables to the Database >

Generating and Editing a CREATE Statement

The Online Browser allows you to 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.In the Online Browser, right-click the tblZookeepers table.
2.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

3.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]) ) ;

 

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