//创建表,列的内容
-- Create table
create table T_HQ_PC
(
pinpai VARCHAR2(20) not null,
xingh VARCHAR2(40),
jiage NUMBER,
chuchangrq DATE,
shifoutc CHAR(1)
)
tablespace TEST
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
//添加注释
-- Add comments to the columns
comment on column T_HQ_PC.pinpai
is ‘电脑品牌‘;
comment on column T_HQ_PC.xingh
is ‘型号‘;
comment on column T_HQ_PC.jiage
is ‘价格‘;
comment on column T_HQ_PC.chuchangrq
is ‘出厂日期‘;
comment on column T_HQ_PC.shifoutc
is ‘是否停产:1-是;2-否‘;
//创建主键约束
-- Create/Recreate primary, unique and foreign key constraints
alter table T_HQ_PC
add constraint PK_T_HQ_PC primary key (PINPAI)
using index
tablespace TEST
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
//创建检查约束
-- Create/Recreate check constraints
alter table T_HQ_PC
add constraint CHECK_JIAGE
check (jiage > 1000.00 and jiage < 60000.00);
alter table T_HQ_PC
add constraint CHECK_SHIFOUTC
check (shifoutc = ‘1‘ or shifoutc = ‘2‘);
原文:http://www.cnblogs.com/shadowduke/p/4909721.html