首页 > 数据库技术 > 详细

oracle,PL/SQL新建表

时间:2015-10-26 00:14:27      阅读:388      评论:0      收藏:0      [点我收藏+]

创建用户

-- Create the user
create user U_HQ_JAVA
default tablespace USERS
temporary tablespace TEMP
profile DEFAULT
password expire;
-- Grant/Revoke role privileges
grant connect to U_HQ_JAVA;
grant dba to U_HQ_JAVA;
-- Grant/Revoke system privileges
grant unlimited tablespace to U_HQ_JAVA;

创建主键
-- Create/Recreate primary, unique and foreign key constraints
alter table T_U_HQ_JAVA
add constraint pk_xuhao primary key ();

创建表,添加列

-- Create table
create table T_U_HQ_JAVA
(
bum VARCHAR2(10),
rens NUMBER,
xiuxrx NUMBER,
suoxuhc VARCHAR2(60),
suoxhcsl NUMBER,
gongfeish NUMBER
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 100M
next 1M
minextents 1
maxextents unlimited
);
-- Add comments to the columns
comment on column T_U_HQ_JAVA.bum
is ‘部门‘;
comment on column T_U_HQ_JAVA.rens
is ‘人数‘;
comment on column T_U_HQ_JAVA.xiuxrx
is ‘休假人数‘;
comment on column T_U_HQ_JAVA.suoxuhc
is ‘所需耗材‘;
comment on column T_U_HQ_JAVA.suoxhcsl
is ‘所需耗材数量‘;
comment on column T_U_HQ_JAVA.gongfeish
is ‘公费损耗‘;
-- Create/Recreate check constraints

添加限制检查

alter table T_U_HQ_JAVA
add constraint CHECE_XIUXRX
check (xiuxrx < 2);

oracle,PL/SQL新建表

原文:http://www.cnblogs.com/wgbs25673578/p/4910045.html

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