The following are CREATE TABLE statement examples:
create table employee
(eno smallint,
ename varchar(20) not null with default,
age integer1,
job smallint,
salary float4,
dept smallint)
with journaling;
create table debts
(acct varchar(20) not null not default,
owes money,
logical_key object_key with system_maintained,
due date not null with default);
create table highincome as
select eno
from employee
where salary >
(select avg (salary)
from employee);
create table emp as
select eno from employee
with location = (location1, location2),
allocation = 1000;
create table dept (
dname char(10)
location char(10) default 'LA'
creation_date date default '1/1/93',
budget money default 100000,
expenses money default 0);
create table dept (
dname char(10),
budget money default 100000,
expenses money default 0,
check (budget >= expenses));
create table dept (
deptno char(5) primary key,
dname char(10) not null,
dlocationchar(10) not null,
unique (dname, dlocation));
create table emp (
salary money with null not default,
hiredate date with null not default,
sickdays float with null with default 5.0);
create table department (dept_id char(6) not null primary key with structure = hash, dept_name char(20));
create table department (dept_id char(6) not null, dept_name char(20));
modify department to hash unique on dept_id;
modify department to unique scope = statement;
alter table department add primary key (dept_id)
with index = base table structure;
create table employee (empl_no int not null
unique with location = (ixloc1),
emp_name char(20) not null,
dept_id char(6) references department (dept_id) with no index,
mgrno int references employee (empl_no));
create table assignment (empl_no int not null
references employee (empl_no) with (index = assnpkix,
location = (ixloc2)),
proj_id int not null references project (proj_id),
task char(20),
primary key (empl_no, proj_id) with index =
assnpkix);
Referential action:
create table employee (empl_no int not null
unique with location = (ixloc1),
emp_name char(20) not null,
dept_id char(6) references department (dept_id)
on delete cascade on update cascade with no index,
mgrno int references employee (empl_no) on update cascade
on delete set null);
CREATE TABLE foo (
i INTEGER NOT NULL WITH DEFAULT,
str VARCHAR(10) NOT NULL WITH DEFAULT
) WITH JOURNALING,
PARTITION = (AUTOMATIC
PARTITION p1 WITH LOCATION=(ii_database),
2 PARTITIONS WITH LOCATION=(loc1, loc2),
PARTITION p4);
CREATE TABLE table1 (
i INTEGER NOT NULL WITH DEFAULT,
str VARCHAR(10) NOT NULL WITH DEFAULT
) WITH PARTITION = (LIST ON i,str
PARTITION p1 VALUES (1,'one')
WITH LOCATION=(ii_database),
PARTITION p2 VALUES ((2,'two'),(3,'three'))
WITH LOCATION=(loc1, loc2),
PARTITION p3 VALUES DEFAULT);
CREATE TABLE range (
i INTEGER NOT NULL WITH DEFAULT,
str VARCHAR(10) NOT NULL WITH DEFAULT
) WITH PARTITION = (RANGE ON str
PARTITION p1 VALUES < 'A'
WITH LOCATION=(ii_database),
PARTITION p2 VALUES <= 'Z'
WITH LOCATION=(loc1, loc2),
PARTITION p4 VALUES > 'Z');
CREATE TABLE lineitems (
shipdate DATE NOT NULL WITH DEFAULT,
partno INTEGER NOT NULL WITH DEFAULT,
stuff VARCHAR(10) NOT NULL WITH DEFAULT
) WITH PARTITION = (
(RANGE ON shipdate
PARTITION p1 VALUES <= '31-Dec-2001',
PARTITION p2 VALUES <= '31-Dec-2002',
PARTITION p3 VALUES <= '31-Dec-2003',
PARTITION p4 VALUES > '31-Dec-2003')
SUBPARTITION
(HASH ON partno 8 PARTITIONS WITH LOCATION = (loc2)));
);