首页 > 数据库技术 > 详细

Oracle创建表

时间:2015-10-25 22:28:46      阅读:298      评论:0      收藏:0      [点我收藏+]

//创建表,列的内容

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

Oracle创建表

原文:http://www.cnblogs.com/shadowduke/p/4909721.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!