您的位置:首页 > 数据库

数据库用户的建立,表空间的建立,数据的编辑

2015-10-25 16:15 204 查看
//表空间
CREATE SMALLFILE TABLESPACE "ZUOYE" DATAFILE 'D:\ORACLE\11G\ORADATA\ORCL\ZUOYE.DBF' SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO

//表空间的空间修添加
ALTER TABLESPACE "ZUOYE" ADD DATAFILE 'D:\ORACLE\11G\ORADATA\ORCL\ZUOYE1.DBF' SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED

//创建用户
-- Create the user
create user zuoye            //用户名
identified by "123654789"        //密码
default tablespace ZUOYE        //表空间
temporary tablespace TEMP;        //临时表空间
-- Grant/Revoke role privileges
grant connect to zuoye;            //授予connect权限
grant dba to zuoye;            //授予dba权限

//列的内容
-- Create table
create table T_HQ_ZYl
(
"bianh"   number not null,
"xingm"   varchar2(10) not null,
"xingb"   number default 1 not null,
"nianl"   number not null,
"jiatzz"  varchar2(50),
"xins"    number default 0 not null,
"gongzsj" number not null
)
;

//注释
-- Add comments to the columns
comment on column T_HQ_ZYl."bianh"
is '编号';
comment on column T_HQ_ZYl."xingm"
is '姓名';
comment on column T_HQ_ZYl."xingb"
is '性别:男-1;女-2;';
comment on column T_HQ_ZYl."nianl"
is '年龄';
comment on column T_HQ_ZYl."jiatzz"
is '家庭住址';
comment on column T_HQ_ZYl."xins"
is '薪水';
comment on column T_HQ_ZYl."gongzsj"
is '工作时间';

//检查,约束
-- Create/Recreate check constraints
alter table T_HQ_ZY
add constraint CHECK_BIANH
check (bianh != bianh);
alter table T_HQ_ZY
add constraint CHECK_NIANL
check (nianl>20 and nianl<50);
alter table T_HQ_ZY
add constraint CHECK_XINGB
check (xingb = 1 or xingb = 2);


创建用户前需要先创建表空间。

创建表空间时注意将表空间文件的后缀名添加上!比如:biaokongjian.DBF 。 .DBF 就是需要注意的文件后缀
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: