您的位置:首页 > 数据库 > Oracle

oracle,PL/SQL新建表

2015-10-25 23:44 489 查看
创建用户

-- 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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: