테이블 생성을 위해서 CREATE TABLE 구문을 이용한다.
CREATE { CLASS | TABLE } table_name
[ {UNDER | AS SUBCLASS OF } super_class_name [ {, super_class_name }_ ] ]
[ TABLE ATTRIBUTE
( table_attr_definition_list ) ]
[ ( attr_definition | table_constraint
[ { , attr_definition | table_constraint_definition }_ ] ) ]
[ METHOD method_definition_list ] ]
[ FILE path_name_list ] ]
[ INHERIT resolution_list [ {, resolution_list }_ ] ] [ ; ]
super_class_name :
[ user_name.]classname
table_attr_definition :
attribute_name datatype { [ DEFAULT value ] | [ NOT NULL ] }
attr_definition :
attribute_name datatype [ { SHARED [ value ] | DEFAULT value } ] [AUTO_INCREMENT ...] [ constraints ]
constraints :
NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY ...
table_constraint_definition :
[ CONSTRAINT constraint_name ] {[ UNIQUE | PRIMARY KEY | FOREIGN KEY ]}
(attribute_name [{, attribute_name} ...])
method_definition :
[ CLASS ] method_name [ ( [ arg_type_list ] ) ]
[ result_type ] [ FUNCTION method_implementation_name ]
arg_type :
datatype
result_type :
datatype
resolution_list :
attr_mthd_name OF super_class_name [ AS alias ]
다음은 데모로 제공된 올림픽 데이터베이스의 olympic 테이블을 생성하는 예제이다.
CREATE TABLE olympic (
host_year INT NOT NULL PRIMARY KEY,
host_nation VARCHAR(40) NOT NULL,
host_city VARCHAR(20) NOT NULL,
opening_date DATE NOT NULL,
closing_date DATE NOT NULL,
mascot VARCHAR(20) ,
slogan VARCHAR(40) ,
introduction VARCHAR(1500)
);