Oracle创建表

//创建表,列的内容

-- 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');

posted on 2015-10-25 21:49  锿咚公爵  阅读(190)  评论(0编辑  收藏  举报