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

//表空间
CREATE SMALLFILE TABLESPACE "ZUOYE" DATAFILE 'D:ORACLE11GORADATAORCLUOYE.DBF' SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO

//表空间的空间修添加
ALTER TABLESPACE "ZUOYE" ADD DATAFILE 'D:ORACLE11GORADATAORCLUOYE1.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  就是需要注意的文件后缀

原文地址:https://www.cnblogs.com/name-hanlin/p/4908925.html