Creating tables

Creating tables in Sybase Central

To create a table using Sybase Central, see “Managing tables” in Introduction to Sybase IQ.

SQL statement for creating tables

The SQL statement for creating tables is CREATE TABLE.

This section describes how to use the CREATE TABLE statement. The examples in this section use the sample database. To try the examples, run DBISQL and connect to the sample database with user ID DBA and password SQL.

For information on connecting to the sample database from DBISQL, see “Connecting to the sample database from Sybase Central or DBISQL.”

You can create tables with other tools in addition to DBISQL. The SQL statements described here are independent of the tool you are using.

Creating tables with SQL

The following statement creates a new, permanent IQ table to describe qualifications of employees within a company. The table has columns to hold an identifying number, a name, and a type (say technical or administrative) for each skill.

CREATE TABLE skill (
skill_id INTEGER NOT NULL,
skill_name CHAR( 20 ) NOT NULL,
skill_type CHAR( 20 ) NOT NULL
)

You can execute this command by typing it into the DBISQL command window, and pressing the execute key (F9).

By internally executing the COMMIT statement before creating the table, Sybase IQ makes permanent all previous changes to the database. There is also a COMMIT after the table is created.

For a full description of the CREATE TABLE statement, see “CREATE TABLE statement” in the Sybase IQ Reference Manual. For information about building constraints into table definitions using CREATE TABLE, see Chapter 9, “Ensuring Data Integrity”.

Specifying data types

When you create a table, you specify the type of data that each column holds.

You can also define customized data types for your database. In the Sybase IQ Reference Manual, see Chapter 4, “SQL Data Types,” for a list of supported data types, or see the CREATE DOMAIN statement for details on how to create a customized data type.