Creates a new table.
create table [database.[owner].]table_name (column_name datatype {null | not null} [{, next_column }...]) [on segment_name]
is the name of the new table. It conforms to the rules for identifiers and is unique within the database and to the owner.
is the name of the column in the table. It conforms to the rules for identifiers and is unique in the table.
is the datatype of the column. Only system datatypes are used. As shown in Table C-3, several datatypes expect a length, n, in parentheses:
datatype(n)
specifies a null value if a user does not provide a value during an insertion and no default exists (for null), or that a user must provide a non-null value if no default exists (for not null).
indicates that you can include additional column definitions (separated by commas) using the same syntax described for a column definition.
create table titles (title_id tid not null, title varchar(80) not null, type char(12) not null, pub_id char(4) null, price money null, advance money null, total_sales int null, notes varchar(200) null, pubdate datetime not null, contract bit not null)
T-SQL allows you to specify null or not null, with a default of not null. DB2 allows only not null to be specified, and the default is null. The following table shows how the DB2 access service transforms this clause.
Transact-SQL specification |
Transformed to... |
---|---|
null |
<nothing> |
not null |
not null |
<nothing> |
not null |
The following table shows the DB2 access service transformation of datatype specifications.
Transact-SQL datatype |
DB2 datatype |
---|---|
tinyint |
SMALLINT |
smallint |
SMALLINT |
int |
INT |
numeric(p,s) |
NUMERIC(p,s) |
decimal(p,s) |
DECIMAL(p,s) |
float (double precision) |
FLOAT |
real |
REAL |
smallmoney |
DECIMAL(10,4) |
money |
DECIMAL(19,4) |
smalldatetime |
TIMESTAMP |
datetime |
TIMESTAMP |
char(n) |
CHAR(n) |
varchar(n) |
VARCHAR(n) |
text |
LONG VARCHAR(n) |
binary(n) |
CHAR(n) FOR BIT DATA |
varbinary(n) |
VARCHAR(n) FOR BIT DATA |
image |
LONG VARCHAR (n) FOR BIT DATA |
bit |
SMALLINT |
Copyright © 2005. Sybase Inc. All rights reserved. |