3. Statements : OpenROAD SQL Statements : Create Table Statement : Examples—Create Table Statement
 
Share this page                  
Examples—Create Table Statement
The following are create table statement examples:
1. Create the employee table with columns eno, ename, age, job, salary, and dept, with journaling enabled.
create table employee
   (eno smallint,
    ename varchar(20) not null with default,
    age integer1,
    job smallint,
    salary float4,
    dept smallint)
   with journaling;
2. Create a table listing employee numbers for employees who make more than the average salary.
create table highincome AS
    select eno
    from employee
    where salary >
    (select avg (salary)
     from employee);
3. Create a table that spans two locations. Specify number of pages to be allocated for the table.
create table emp as
    select eno from employee
    with location = (location1, location2),
    allocation = 1000;
4. Create a table specifying defaults.
create table dept (
    dname char(10),
    location char(10) not null with default 'LA'
    creation_date date not null with default '1/1/99',
    budget money not null with default 100000,
    expenses money not null with default 0);
5. Base table structure is hash unique on dept_id.
create table department (dept_id char(6) not null, dept_name char(20));
modify department to hash unique on dept_id;