Oracle设计表、批处理方式快速导入到数据库示例

159 篇文章 113 订阅
86 篇文章 1 订阅

环境

 

Oracle 11.2.0 + SQL Plus + PowerDesigner 15.1

 

问题

 

Oracle设计表、批处理方式快速导入到数据库

 

解决

 

1.首先使用PowerDesigner设计表结构、视图等

 

 

2.通过PowerDesigner导出表结构、视图结构

 

011table.sql

drop trigger GENID_T_DEPT
/

drop trigger TR_INSERT_EMP
/

drop trigger TR_DEL_EMP
/

drop trigger TR_UPDATE_EMP
/

drop trigger GENID_T_EMP_POST
/

drop trigger GENID_T_EMP_TITLE
/

drop trigger GENID_T_ROLES
/

drop trigger TR_DEL_ROLE
/

drop trigger GENID_T_USERS
/

drop trigger TR_DEL_USER
/

alter table T_DEPT
   drop constraint FK_T_DEPT_FK_DEPART_T_DEPT
/

alter table T_EMPLOYEE
   drop constraint FK_T_EMPLOY_REFERENCE_T_DEPT
/

alter table T_EMPLOYEE
   drop constraint FK_T_EMPLOY_REFERENCE_T_EMP_TI
/

alter table T_EMPLOYEE
   drop constraint FK_T_EMPLOY_REFERENCE_T_EMP_PO
/

alter table T_MODULES
   drop constraint FK_MODULES_REFERENCE_MODULES
/

alter table T_ROLE_MODULE
   drop constraint FK_MODULE_PRIVS_REF_MODULES
/

alter table T_ROLE_MODULE
   drop constraint FK_T_ROLE_M_REFERENCE_T_ROLES
/

alter table T_USERS
   drop constraint FK_T_USERS_REFERENCE_T_EMPLOY
/

alter table T_USER_ROLES
   drop constraint FK_T_USER_R_REFERENCE_T_ROLES
/

alter table T_USER_ROLES
   drop constraint FK_T_USER_R_REFERENCE_T_USERS
/

drop table T_DEPT cascade constraints
/

drop table T_EMPLOYEE cascade constraints
/

drop table T_EMP_POST cascade constraints
/

drop table T_EMP_TITLE cascade constraints
/

drop table T_MODULES cascade constraints
/

drop table T_ROLES cascade constraints
/

drop table T_ROLE_MODULE cascade constraints
/

drop table T_USERS cascade constraints
/

drop table T_USER_ROLES cascade constraints
/

drop sequence SEQ_HR_DEPT
/

drop sequence SEQ_HR_EMP
/

drop sequence SEQ_HR_POSTTITLE
/

drop sequence SEQ_SYS_ROLE
/

drop sequence SEQ_SYS_USER
/

create sequence SEQ_HR_DEPT
increment by 1
start with 1001
/

create sequence SEQ_HR_EMP
increment by 1
start with 1001
/

create sequence SEQ_HR_POSTTITLE
increment by 1
start with 1001
/

create sequence SEQ_SYS_ROLE
  start with 1
/

create sequence SEQ_SYS_USER
  start with 1001
/

/*==============================================================*/
/* Table: T_DEPT                                                */
/*==============================================================*/
create table T_DEPT  (
   N_DEPT_ID            NUMBER                          not null,
   VC_DEPT_NAME         VARCHAR2(100)                   not null,
   N_PARENT_ID          NUMBER,
   VC_LOCATION          VARCHAR2(200),
   VC_DESC              VARCHAR2(1000),
   constraint PK_T_DEPT primary key (N_DEPT_ID)
)
/

comment on table T_DEPT is
'组织机构表'
/

comment on column T_DEPT.N_DEPT_ID is
'组织机构ID'
/

comment on column T_DEPT.VC_DEPT_NAME is
'组织机构名称'
/

comment on column T_DEPT.N_PARENT_ID is
'上级组织机构ID'
/

comment on column T_DEPT.VC_LOCATION is
'联系电话'
/

comment on column T_DEPT.VC_DESC is
'描述'
/

/*==============================================================*/
/* Table: T_EMPLOYEE                                            */
/*==============================================================*/
create table T_EMPLOYEE  (
   N_EMP_ID             NUMBER                          not null,
   VC_EMP_CODE          VARCHAR2(20)                    not null,
   VC_EMP_NAME          VARCHAR2(50)                    not null,
   N_DEPT_ID            NUMBER,
   N_POST_ID            NUMBER,
   N_TITLE_ID           NUMBER,
   N_STATUS             NUMBER(1)                      default 1 not null,
   D_HIREDATE           DATE                           default SYSDATE not null,
   VC_IDCARD_ID         VARCHAR2(30),
   VC_NATIVE_PLACE      VARCHAR2(30),
   N_GENDER             NUMBER(1),
   N_NATION             NUMBER(2),
   D_BIRTHDAY           DATE,
   VC_EMAIL             VARCHAR2(30)                    not null,
   constraint PK_T_EMPLOYEE primary key (N_EMP_ID)
)
/

comment on table T_EMPLOYEE is
'员工信息表'
/

comment on column T_EMPLOYEE.N_EMP_ID is
'人员信息ID'
/

comment on column T_EMPLOYEE.VC_EMP_CODE is
'职工代码'
/

comment on column T_EMPLOYEE.VC_EMP_NAME is
'姓名'
/

comment on column T_EMPLOYEE.N_DEPT_ID is
'组织机构ID'
/

comment on column T_EMPLOYEE.N_POST_ID is
'职位ID'
/

comment on column T_EMPLOYEE.N_TITLE_ID is
'职称ID'
/

comment on column T_EMPLOYEE.N_STATUS is
'1 在职 2 离职 '
/

comment on column T_EMPLOYEE.D_HIREDATE is
'入司时间'
/

comment on column T_EMPLOYEE.VC_IDCARD_ID is
'身份证号码'
/

comment on column T_EMPLOYEE.VC_NATIVE_PLACE is
'籍贯'
/

comment on column T_EMPLOYEE.N_GENDER is
'性别'
/

comment on column T_EMPLOYEE.N_NATION is
'民族'
/

comment on column T_EMPLOYEE.D_BIRTHDAY is
'出生日期'
/

comment on column T_EMPLOYEE.VC_EMAIL is
'email邮箱'
/

/*==============================================================*/
/* Table: T_EMP_POST                                            */
/*==============================================================*/
create table T_EMP_POST  (
   N_POST_ID            NUMBER                          not null,
   VC_POST_NAME         VARCHAR2(100)                   not null,
   N_WORK_DETAIL        VARCHAR2(2000),
   constraint PK_T_EMP_POST primary key (N_POST_ID)
)
/

comment on table T_EMP_POST is
'职位表'
/

comment on column T_EMP_POST.N_POST_ID is
'职位ID'
/

comment on column T_EMP_POST.VC_POST_NAME is
'职位名称'
/

comment on column T_EMP_POST.N_WORK_DETAIL is
'工作职责'
/

/*==============================================================*/
/* Table: T_EMP_TITLE                                           */
/*==============================================================*/
create table T_EMP_TITLE  (
   N_TITLE_ID           NUMBER                          not null,
   VC_TITLE             VARCHAR2(100)                   not null,
   VC_DESC              VARCHAR2(200),
   constraint PK_T_EMP_TITLE primary key (N_TITLE_ID)
)
/

comment on table T_EMP_TITLE is
'职称表'
/

comment on column T_EMP_TITLE.N_TITLE_ID is
'职称ID'
/

comment on column T_EMP_TITLE.VC_TITLE is
'职称名称'
/

comment on column T_EMP_TITLE.VC_DESC is
'描述'
/

/*==============================================================*/
/* Table: T_MODULES                                             */
/*==============================================================*/
create table T_MODULES  (
   N_MODULE_ID          NUMBER                          not null,
   N_PARENT_ID          NUMBER,
   VC_MODULE_NAME       VARCHAR2(100)                   not null,
   N_MODULE_TYPE        NUMBER(2)                       not null,
   VC_ICON_LINK         VARCHAR2(500),
   VC_LINK              VARCHAR2(500),
   constraint PK_T_MODULES primary key (N_MODULE_ID)
)
/

comment on table T_MODULES is
'模块列表主要存放系统中可用的页面'
/

comment on column T_MODULES.N_MODULE_ID is
'模块标识'
/

comment on column T_MODULES.N_PARENT_ID is
'所属模块ID'
/

comment on column T_MODULES.VC_MODULE_NAME is
'名称'
/

comment on column T_MODULES.N_MODULE_TYPE is
'类别'
/

comment on column T_MODULES.VC_ICON_LINK is
'图标'
/

comment on column T_MODULES.VC_LINK is
'链接'
/

/*==============================================================*/
/* Table: T_ROLES                                               */
/*==============================================================*/
create table T_ROLES  (
   N_ROLE_ID            NUMBER                          not null,
   VC_NAME              VARCHAR2(30)                    not null,
   VC_DESC              VARCHAR2(1000),
   constraint PK_T_ROLES primary key (N_ROLE_ID)
)
/

comment on table T_ROLES is
'角色表'
/

comment on column T_ROLES.N_ROLE_ID is
'角色ID'
/

comment on column T_ROLES.VC_NAME is
'角色名称'
/

comment on column T_ROLES.VC_DESC is
'描述'
/

/*==============================================================*/
/* Table: T_ROLE_MODULE                                         */
/*==============================================================*/
create table T_ROLE_MODULE  (
   N_ROLE_ID            NUMBER                          not null,
   N_MODULE_ID          NUMBER                          not null,
   constraint PK_T_ROLE_MODULE primary key (N_ROLE_ID, N_MODULE_ID)
)
/

comment on table T_ROLE_MODULE is
'角色权限表'
/

comment on column T_ROLE_MODULE.N_ROLE_ID is
'角色ID'
/

comment on column T_ROLE_MODULE.N_MODULE_ID is
'模块标识'
/

/*==============================================================*/
/* Table: T_USERS                                               */
/*==============================================================*/
create table T_USERS  (
   N_USER_ID            NUMBER                          not null,
   VC_LOGIN_NAME        VARCHAR2(30)                    not null,
   VC_PASSWORD          VARCHAR2(64)                    not null,
   VC_USER_NAME         VARCHAR2(30)                    not null,
   D_CREATE_TIME        DATE                           default SYSDATE not null,
   N_STATUS             NUMBER(1)                      default 2 not null,
   N_TYPE               NUMBER(1)                      default 3 not null,
   VC_DESC              VARCHAR2(1000),
   N_EMP_ID             NUMBER,
   constraint PK_T_USERS primary key (N_USER_ID)
)
/

comment on table T_USERS is
'用户表'
/

comment on column T_USERS.N_USER_ID is
'用户ID'
/

comment on column T_USERS.VC_LOGIN_NAME is
'登录名'
/

comment on column T_USERS.VC_PASSWORD is
'密码'
/

comment on column T_USERS.VC_USER_NAME is
'用户名'
/

comment on column T_USERS.D_CREATE_TIME is
'创建时间'
/

comment on column T_USERS.N_STATUS is
'帐户状态'
/

comment on column T_USERS.N_TYPE is
'用户类型'
/

comment on column T_USERS.VC_DESC is
'描述'
/

comment on column T_USERS.N_EMP_ID is
'人员信息ID'
/

/*==============================================================*/
/* Table: T_USER_ROLES                                          */
/*==============================================================*/
create table T_USER_ROLES  (
   N_ROLE_ID            NUMBER                          not null,
   N_USER_ID            NUMBER                          not null,
   constraint PK_T_USER_ROLES primary key (N_ROLE_ID, N_USER_ID)
)
/

comment on table T_USER_ROLES is
'用户角色表'
/

comment on column T_USER_ROLES.N_ROLE_ID is
'角色ID'
/

comment on column T_USER_ROLES.N_USER_ID is
'用户ID'
/

alter table T_DEPT
   add constraint FK_T_DEPT_FK_DEPART_T_DEPT foreign key (N_PARENT_ID)
      references T_DEPT (N_DEPT_ID)
/

alter table T_EMPLOYEE
   add constraint FK_T_EMPLOY_REFERENCE_T_DEPT foreign key (N_DEPT_ID)
      references T_DEPT (N_DEPT_ID)
/

alter table T_EMPLOYEE
   add constraint FK_T_EMPLOY_REFERENCE_T_EMP_TI foreign key (N_TITLE_ID)
      references T_EMP_TITLE (N_TITLE_ID)
/

alter table T_EMPLOYEE
   add constraint FK_T_EMPLOY_REFERENCE_T_EMP_PO foreign key (N_POST_ID)
      references T_EMP_POST (N_POST_ID)
/

alter table T_MODULES
   add constraint FK_MODULES_REFERENCE_MODULES foreign key (N_PARENT_ID)
      references T_MODULES (N_MODULE_ID)
/

alter table T_ROLE_MODULE
   add constraint FK_MODULE_PRIVS_REF_MODULES foreign key (N_MODULE_ID)
      references T_MODULES (N_MODULE_ID)
/

alter table T_ROLE_MODULE
   add constraint FK_T_ROLE_M_REFERENCE_T_ROLES foreign key (N_ROLE_ID)
      references T_ROLES (N_ROLE_ID)
/

alter table T_USERS
   add constraint FK_T_USERS_REFERENCE_T_EMPLOY foreign key (N_EMP_ID)
      references T_EMPLOYEE (N_EMP_ID)
/

alter table T_USER_ROLES
   add constraint FK_T_USER_R_REFERENCE_T_ROLES foreign key (N_ROLE_ID)
      references T_ROLES (N_ROLE_ID)
/

alter table T_USER_ROLES
   add constraint FK_T_USER_R_REFERENCE_T_USERS foreign key (N_USER_ID)
      references T_USERS (N_USER_ID)
/


CREATE OR REPLACE TRIGGER GenID_t_dept
  BEFORE INSERT ON t_dept
  FOR EACH ROW
BEGIN
   SELECT SEQ_HR_DEPT.NEXTVAL
      INTO :new.N_DEPT_ID
      FROM dual;
END GenID_t_dept;
/


create or replace trigger TR_INSERT_EMP  after  INSERT ON   t_employee
  for   each   row 
begin
 
      insert into t_users (N_EMP_ID,VC_LOGIN_NAME,VC_PASSWORD,VC_USER_NAME,N_STATUS,N_TYPE)
      values ( :new.n_emp_id ,:new.vc_email,:new.vc_emp_code,:new.vc_emp_name,2,2);
end;
/


create or replace trigger TR_DEL_EMP before delete ON   t_employee
  for   each   row
begin
        delete from t_users where n_emp_id=:old.n_emp_id;
 end;
/


create or replace trigger TR_UPDATE_EMP  after  UPDATE ON   t_employee
  for   each   row

declare userStatus number(1);
begin
     userStatus := 1;

     IF UPDATING ('N_STATUS')  THEN
        IF (:new.n_status=1) and (:old.n_status=2)  THEN
           userStatus := 2;                             
        END IF;
        IF :new.n_status=2 THEN
           userStatus := 2;
        END IF;
        update  t_users  set N_STATUS=userStatus where n_emp_id= :old.n_emp_id ;
      END IF;
     IF UPDATING ('VC_EMAIL') THEN
         update  t_users  set vc_login_name=:new.vc_email
         where n_emp_id= :old.n_emp_id ;
      END IF;
     IF UPDATING ('VC_EMP_NAME') THEN
         update  t_users  set vc_user_name=:new.vc_emp_name
         where n_emp_id= :old.n_emp_id ;
      END IF;

end;
/


CREATE OR REPLACE TRIGGER GenID_t_emp_post
  BEFORE INSERT ON t_emp_post
  FOR EACH ROW
BEGIN
   SELECT SEQ_HR_POSTTITLE.NEXTVAL
      INTO :new.N_POST_ID
      FROM dual;
END GenID_t_emp_post;
/


CREATE OR REPLACE TRIGGER GenID_t_emp_title
  BEFORE INSERT ON t_emp_title
  FOR EACH ROW
BEGIN
   SELECT SEQ_HR_POSTTITLE.NEXTVAL
      INTO :new.N_TITLE_ID
      FROM dual;
END GenID_t_emp_title;
/


CREATE OR REPLACE TRIGGER GenID_t_roles
  BEFORE INSERT ON t_roles
  FOR EACH ROW
BEGIN
   SELECT seq_sys_role.NEXTVAL
      INTO :new.N_ROLE_ID
      FROM dual;
END GenID_t_roles;
/


create or replace trigger TR_DEL_ROLE  before   DELETE ON   t_roles  
  for   each   row       
begin
     delete from t_user_roles  where   n_role_id= :old.n_role_id;
     delete from T_ROLE_MODULE where n_role_id =  :old.n_role_id ;
end;
/


CREATE OR REPLACE TRIGGER GenID_t_users
  BEFORE INSERT ON t_users
  FOR EACH ROW
BEGIN
   SELECT seq_sys_user.NEXTVAL
      INTO :new.N_USER_ID
      FROM dual;
END GenID_t_users;
/


create or replace trigger TR_DEL_USER before delete ON   t_users
  for   each   row
begin
        delete from T_USER_ROLES where n_user_id=:old.n_user_id;
end;
/

 021view.sql

 

drop view V_EMPLOYEE;

drop view V_ROLE;

drop view V_USERS;



/*==============================================================*/
/* View: V_EMPLOYEE                                             */
/*==============================================================*/
create or replace view V_EMPLOYEE as
select a.*,
   decode(a.n_post_id,null,'',(select vc_post_name from t_emp_post where n_post_id=a.n_post_id))  vc_post_name,
   decode(a.n_title_id,null,'',(select vc_title from t_emp_title where n_title_id=a.n_title_id))  vc_title,
   decode(a.n_dept_id,null,'',(select vc_dept_name from t_dept where n_dept_id=a.n_dept_id)) vc_dept_name
 from t_employee a;

/*==============================================================*/
/* View: V_ROLE                                                 */
/*==============================================================*/
create or replace view V_ROLE as
SELECT N_ROLE_ID,VC_NAME,VC_DESC,
(SELECT COUNT(*) FROM t_user_roles where t_user_roles.n_role_id=a.n_role_id) userNum,
(SELECT Count(*) FROM T_ROLE_MODULE where  a.n_role_id=T_ROLE_MODULE.n_role_id )
 moduleNum FROM t_ROLES a;

comment on table V_ROLE is
'角色视图';

/*==============================================================*/
/* View: V_USERS                                                */
/*==============================================================*/
create or replace view V_USERS as
select
   a.*,
   decode(b.vc_emp_name,null,decode(a.vc_user_name,null,a.vc_login_name,a.vc_user_name),b.vc_emp_name) vc_emp_name,
   b.n_dept_id,
   b.VC_DEPT_NAME,
   b.n_title_id,
   b.vc_title,
   b.n_post_id,
   b.vc_post_name,
   b.n_status empStatus,
   b.vc_email
from
   t_users a,
   v_employee b
where
 a.n_emp_id = b.n_emp_id(+);


 

3.编写初始化系统、权限、测试数据的sql

 

 031init_sys.sql
prompt 系统管理员 id 默认为1
ALTER TRIGGER GENID_t_users DISABLE;
insert into t_users (n_user_id,vc_login_name,vc_user_name,D_create_time,n_status,n_type,vc_password,N_EMP_ID) 
            values (1,'admin','管理员',trunc(sysdate,'dd'),1,1,'admin',null);
ALTER TRIGGER GENID_t_users ENABLE;

prompt 组织机构

032init_privs.sql
set escape '\'

insert into t_modules values (1,null,'模块树',0,null,null);

rem ************************
rem 初始化人资管理需处理权限       20102   2:人资管理子系统  01:功能模块编号  02:功能编号
rem *************************
insert into t_modules values (20000,1,'人资管理',1,null,null);
  insert into t_modules values (20100,20000,'个人事务',2,null,null);
    insert into t_modules  values (20101,20100,'自动提醒',3,'yhzsz.gif','/hr/hrself/autoRemind.do'); 
    insert into t_modules  values (20102,20100,'收入排行',3,'sqgl.gif','/waiting.jsp'); 
    insert into t_modules  values (20103,20100,'个人信息',3,'bmsz.gif','/hr/hrself/selfInfo.do'); 
    insert into t_modules  values (20104,20100,'工资信息',3,'grrc.gif','/hr/hrself/selfSalary.do'); 
    insert into t_modules  values (20105,20100,'密码修改',3,'dagl.gif','/hr/hrself/password/password_set.jsp'); 
    insert into t_modules  values (20106,20100,'员工通讯录',3,'0986.gif','/hr/contact/index.jsp');

   insert into t_modules values (20200,20000,'基础数据维护',2,null,null);
    insert into t_modules  values (20201,20200,'日期参数设置',3,'kqsp.gif','/hr/sysvalue/datevalue/datevalue_frame.jsp'); 
    insert into t_modules values (20202,20200,'职位类别设置',3,'dbgl.gif','/hr/sysvalue/compensation/compensation_frame.jsp'); 
    insert into t_modules  values (20205,20200,'工龄工资参数设置',3,'dajy.gif','/hr/sysvalue/wages/wages_frame.jsp'); 
    insert into t_modules values (20206,20200,'社保参数管理',3,'lygl.gif','/hr/sysvalue/insurance/insurance_frame.jsp');
    insert into t_modules values (20207,20200,'公积金参数设置',3,'gjj.gif','/hr/sysvalue/cpf/cpf_frame.jsp'); 
    insert into t_modules values (20208,20200,'个税参数管理',3,'sqgl.gif','/hr/sysvalue/incometex/incometex_frame.jsp');
    insert into t_modules values (20209,20200,'缺勤扣款设置',3,'grmb.gif','/hr/sysvalue/checkrule/checkrule_frame.jsp');
    insert into t_modules values (20210,20200,'警戒线设置',3,'zwsz.gif','/hr/sysvalue/baseLineGet.do');



  insert into t_modules  values (20300,20000,'组织机构管理',2,null,null); 
     insert into t_modules values (20301,20300,'部门维护',3,'bmsz.gif','/hr/deptman/dept/dept_frame.jsp'); 
     insert into t_modules values (20302,20300,'历史记录管理',3,'gwsz.gif','/hr/deptman/depthistory/history_frame.jsp'); 
     insert into t_modules values (20303,20300,'机构图管理',3,'zwsz.gif','/hr/deptman/graphic/graphic_frame.jsp'); 



  insert into t_modules values (20400,20000,'职位职级管理',2,null,null); 
    insert into t_modules values (20401,20400,'职位管理',3,'grmb.gif','/hr/post/postmanage/postmanage_frame.jsp');

    insert into t_modules values (20402,20400,'职级管理',3,'yhwh.gif','/hr/post/title/title_frame.jsp');

    insert into t_modules  values (20403,20400,'编制管理',3,'rswh.gif','/hr/post/deptpost/deptpost_frame.jsp'); 
		
   insert into t_modules  values (20404,20400,'绩效评估表编排',3,'sydj.gif','/hr/post/perfomance/perfomance_frame.jsp');

  insert into t_modules values (20500,20000,'员工管理',2,null,null); 
    insert into t_modules  values (20501,20500,'员工信息管理',3,'grmb.gif','/hr/emp/empinfo/emp_frame.jsp');
    insert into t_modules  values (20502,20500,'员工查询',3,'yhzsz.gif','/hr/emp/empsearch/empsearch_frame.jsp');

    insert into t_modules  values (20503,20500,'员工导入',3,'gzzd.gif','/hr/emp/import/import_frame.jsp');
    insert into t_modules  values (20504,20500,'员工导出',3,'grrc.gif','/hr/emp/empExpSearch.do');

  insert into t_modules values (20600,20000,'培训管理',2,null,null); 
    insert into t_modules values (20601,20600,'培训管理',3,'dzb.gif','/hr/training/trainingCourse/training_frame.jsp');
    insert into t_modules values (20602,20600,'成绩录入',3,'gzzd.gif','/hr/training/trainingScore/trainingScore_frame.jsp');
 
 
  insert into t_modules values (20700,20000,'奖惩管理',2,null,null);  
    insert into t_modules values (20701,20700,'奖惩管理',3,'jsygl.gif','/hr/reward/reward_all_frame.jsp');
   
  insert into t_modules values (20800,20000,'考勤管理',2,null,null); 
    insert into t_modules values (20801,20800,'请销假管理',3,'dzb.gif','/hr/leaveback/leaveback_all_frame.jsp');
 
    insert into t_modules values (20802,20800,'缺勤管理',3,'gzzd.gif','/hr/missing/missing_all_frame.jsp');
    insert into t_modules values (20803,20800,'打卡查询',3,'grmb.gif','/hr/checkreport/checkinout/checkinout_search.jsp');
    insert into t_modules values (20806,20800,'缺勤统计',3,'yhwh.gif','/hr/checkreport/missing/missing_sum_search.jsp');
    insert into t_modules values (20809,20800,'请假统计',3,'grrc.gif','/hr/checkreport/leaveback/leaveback_sum_search.jsp');

  insert into t_modules values (20900,20000,'绩效考核',2,null,null); 
    insert into t_modules  values (20901,20900,'考核打分',3,'gzzd.gif','/hr/evaluate/score/score_frame.jsp');
    insert into t_modules  values (20902,20900,'考核统计',3,'grrc.gif','/hr/evaluate/statistics/statistics_frame.jsp');

  insert into t_modules values (21200,20000,'薪资管理',2,null,null); 
    insert into t_modules  values (21201,21200,'工资表格式管理',3,'gzzd.gif','/hr/salary/table/table_frame.jsp');
    insert into t_modules  values (21202,21200,'工资录入',3,'grrc.gif','/hr/salary/salaryFind.do');
    insert into t_modules  values (21203,21200,'薪资管理',3,'yhwh.gif','/hr/salary/view/salary_frame.jsp');

  insert into t_modules values (21400,20000,'汇总统计',2,null,null); 
    insert into t_modules  values (21401,21400,'人资统计',3,'gzzd.gif','/hr/report/report_frame.jsp');

insert into t_modules values (21500,20000,'设备管理',2,null,null); 
    insert into t_modules  values (21501,21500,'设备类型',3,'gzzd.gif','/hr/device/devicetype/type_frame.jsp');
    insert into t_modules  values (21502,21500,'设备管理',3,'yhwh.gif','/hr/device/devices/devices_frame.jsp');

set escape off   

041init_test.sql
ALTER TRIGGER GENID_T_ROLES DISABLE;
	insert into T_ROLES(N_ROLE_ID,VC_NAME)  values (1,'角色1');
	insert into T_ROLES(N_ROLE_ID,VC_NAME)  values (2,'角色2');
	insert into T_ROLES(N_ROLE_ID,VC_NAME)  values (3,'角色3');
ALTER TRIGGER GENID_T_ROLES ENABLE;

insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,1);
insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,20000);
insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,20100);
insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,20101);
insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,20102);
insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,20103);
insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,20104);
insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,20105);
insert into T_ROLE_MODULE(N_ROLE_ID,N_MODULE_ID) values (1,20106);


 

4.编写main.sql

spool 执行结果.txt

@011table.sql

@021view.sql

@031init_sys.sql

@032init_privs.sql

@041init_test.sql

spool off

commit;

5.Win+R-------->cmd-------->进入到上述sql所在目录-------->sqlplus-------->输入用户名和密码登录到Oracle-------->@main.sql导入sql



Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Wentasy>G:

G:\>cd G:\编程资料\Learning\数据库应用技术 Oracle\用户管理范例

G:\编程资料\Learning\数据库应用技术 Oracle\用户管理范例>sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 5月 23 11:18:10 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

请输入用户名:  wgb
输入口令:

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @main.sql

触发器已删除。


触发器已删除。


触发器已删除。


触发器已删除。


触发器已删除。


触发器已删除。


触发器已删除。


触发器已删除。


触发器已删除。


触发器已删除。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已删除。


表已删除。


表已删除。


表已删除。


表已删除。


表已删除。


表已删除。


表已删除。


表已删除。


序列已删除。


序列已删除。


序列已删除。


序列已删除。


序列已删除。


序列已创建。


序列已创建。


序列已创建。


序列已创建。


序列已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


注释已创建。


表已创建。


注释已创建。


注释已创建。


注释已创建。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


表已更改。


触发器已创建


触发器已创建


触发器已创建


触发器已创建


触发器已创建


触发器已创建


触发器已创建


触发器已创建


触发器已创建


触发器已创建

drop view V_EMPLOYEE
*
第 1 行出现错误: 
ORA-00942: 表或视图不存在 


drop view V_ROLE
*
第 1 行出现错误: 
ORA-00942: 表或视图不存在 


drop view V_USERS
*
第 1 行出现错误: 
ORA-00942: 表或视图不存在 



视图已创建。


视图已创建。


注释已创建。


视图已创建。

系统管理员 id 默认为1

触发器已更改


已创建 1 行。


触发器已更改

组织机构

已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


触发器已更改


已创建 1 行。


已创建 1 行。


已创建 1 行。


触发器已更改


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。


已创建 1 行。

提交完成。
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开。


执行结果

执行前目录结构


 

 

 

执行后目录结构


 

资料下载

 

用户管理范例,点击此处下载。




 

katoonSina  CSDN
@Wentasy 博文仅供参考,欢迎大家来访。如有错误之处,希望批评指正。原创博文如需转载请注明出处,谢谢 :) [CSDN博客]
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值