CREATE 문

<create class statement>

CREATE { CLASS | TABLE } <class name>
[ <subclass definition> ]
[ ( <class element comma list> ) ]
[ CLASS ATTRIBUTE ( <attribute definition comma list> ) ]
[ ( <class constraint or attribute definition comma list> ) ]

<create virtual class statement>

CREATE { VCLASS | VIEW } <class name>
[ <subclass definition> ]
[ CLASS ATTRIBUTE ( <attribute definition comma list> ) ]
[ ( <view attribute definition comma list> ) ]
[ INHERIT <resolution comma list> ]
[ AS <query statement> ]
[ WITH CHECK OPTION ]

<create trigger statement>

CREATE TRIGGER <trigger name>
[ STATUS { ACTIVE | INACTIVE } ]
[ PRIORITY <trigger key> ]
<trigger event time> <event specification>
[ IF <trigger condition> ]
EXECUTE [ <trigger action time> ] <trigger action>

<create serial statement>

CREATE SERIAL <serial name>
[ START WITH <integer literal> ]

<subclass definition>

AS SUBCLASS OF <class name comma list>

<class constraint or attribute definition>

{ <class constraint definition> | <attribute definition> }

<class constraint definition>

[ CONSTRAINT <constraint name> ] UNIQUE ( <attribute name comma list> )
| [ PRIMARY KEY ( <attribute name comma list> ) ]
| [referential constraint]

<attribute definition>

<general attribute name> <attribute type>
[ <default or shared> ]
[ <attribute constraint list> ]

<view attribute definition>

<attribute definition> | <attribute name>

<class element>

<attribute definition> | <class constraint>

<resolution comma list>

<resolution> [ { , <resolution> }... ]

<resolution>

<general attribute name> OF <class name> [ AS <attribute name> ]

<view attribute definition comma list>

<view attribute definition> [ { , <view attribute definition> }... ]

<view attribute definition>

<attribute definition> | <attribute name>

<trigger key>

<unsigned real literal>

<trigger event time>

BEFORE | AFTER | DEFERRED

<event specification>

INSERT ON <event class target>
| STATEMENT INSERT ON <event class target>
| UPDATE ON { <event class target> | <event class attribute target> }
| STATEMENT UPDATE ON { <event class target> | <event class attribute target> }
| DELETE ON <event class target>
| STATEMENT DELETE ON <event class target>
| COMMIT
| ROLLBACK

<event class target>

<class name>

<event class attribute target>

<class name> ( <attribute name> )

<trigger condition>

<search condition>

<trigger action time>

AFTER | DEFERRED

<trigger action>

REJECT
| INVALIDATE TRANSACTION
| PRINT <string literal>
| <call statement>
| <insert statement>
| <delete statement>
| <update statement>

<general attribute name>

[ CLASS ] <attribute name>

<general method name>

[ CLASS ] <method name>

<attribute type>

<domain name>

<argument type>

<domain name>

<result type>

<domain name>

<referential constraint>

FOREIGN KEY
[constraint name] (attribute name comma list)
REFERENCES
[referenced table name] (attribute name comma list)
[ <referential triggered action> ]

<referential triggered action>

<update rule>
[ <delete rule> [ <cache object rule> ] ]

<update rule>

ON UPDATE <referential action>

<delete rule>

ON DELETE <referential action>

<cache object rule>

ON CACHE OBJECT <cache object column name>

<cache object column name>

<attribute name>

<referential action>

CASCADE | RESTRICT | NO ACTION

예제

CREATE CLASS address (street string, city string);  

CREATE CLASS person (
name string,
birthday date,
residence address,
UNIQUE (name))
METHOD get_age () integer
FILE "/p/xsql/current/bin/person.o";

CREATE CLASS album
(id char(10) NOT NULL PRIMARY KEY,
title varchar(100),
artist varchar(100)
);

CREATE CLASS track
(album char(10),
dsk integer,
posn integer,
song varchar(255),
FOREIGN KEY (album) REFERENCES album(id)
);