Creating Tables

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

Home >  Exploring and Changing the Database Structure >

Creating Tables

Once you are connected to a data source, you can create a new table in DatabaseSpy in several ways.

 

Through a SQL Script

Open an SQL Editor window, enter the required SQL statement (the example below is applicable for SQL Server), and click Execute.

 

CREATE TABLE newTable (
  id INT NOT NULL,
  CONSTRAINT PK_newKey PRIMARY KEY (id)
)

 

You must define at least one column for the new table. Additional columns can be included immediately when the table is created, or added later using drag and drop in the SQL Editor or the Design Editor.

 

From Design Editor

1.Open a Design Editor window (Ctrl+D).
2.Click the New Table ic_create-new-table button in the Design Editor toolbar (or select the menu option Design Editor | Create New Table), and add the required table objects (see also Designing Tables).

design_new-table-db2

Note:By default, DatabaseSpy creates automatically the primary key for new tables. To disable this option, select the menu command Tools | Options | Design Editor, and then clear the option Automatically create primary key for new tables.
3.Click the Execute Change Script ic_execute-sql button in the Database Structure Change Script window.

 

By duplicating or converting an existing table

See Duplicating Tables and Converting Table Structures.


© 2019 Altova GmbH