今天做实验的时候,老师用到,了HR用户,但是不幸的是老师用的10g,我用的是11g,我的竟然没有该用户:
SQL> select username from dba_users where username='HR';
未选定行
最后通过查找各方资料,终于搞定了,把整个过程记录下来和大家分享
创建schema
HR用的到核心脚本是hr_main.sql,正常是在$ORACLE_HOMEE:\demo\schema\human_resources
但是11g默认没有的,整个过程用到的脚本以及作用如下:
Script
Name
Description
hr_analz.sql
Collects statistics on the tables in the schema
hr_code.sql
Creates procedural objects in the schema
hr_comnt.sql
Creates comments for each object in the schema
hr_cre.sql
Creates theHRobjects
hr_dn_c.sql
Adds the distinguished name column used by Oracle Internet
Directory to theemployeesanddepartmentstables
hr_dn_d.sql
Drops the Oracle Internet Directory distinguished name
column fromemployeesanddepartments
hr_drop.sql
Drops theHRschema and all its
objects
hr_idx.sql
Creates indexes on theHRtables
hr_main.sql
Main script for theHRschema; calls
other scripts
hr_popul.sql
Populates the objects
关键的一步就是把所需要的脚本找到,放到$ORACLE_HOMEE:\demo\schema\human_resources
我把脚本放在了邮箱:public_2013_07_09密码:public20130709网盘内。
接下来有了脚本后就可以正式生成HR了:
SYS> conn / as sysdba
SQL>
@E:\ORACLE\product\11.2.0\dbhome_1\demo\schema\human_resources\hr_main.sql
specify password for HR as parameter 1:hr
specify default tablespeace for HR as parameter 2:
输入 2 的值: users
specify temporary tablespace for HR as parameter 3:
输入 3 的值: temp
specify password for SYS as parameter 4:sys
输入 4 的值: sys
specify log path as parameter 5:
输入 5 的值:E:\ORACLE\oradata
.
.
.
.
Comment created.
Commit complete.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
SYS> select username from dba_users where username='HR';
USERNAME
------------------------------
HR
说明HR已创建,接下来以HR用户登录看是否所有的表都已生成:
SQL> conn hr/hr
已连接。
SQL> select tname from tab;
TNAME
------------------------------
COUNTRIES
DEPARTMENTS
EMPLOYEES
JOBS
JOB_HISTORY
LOCATIONS
REGIONS
已选择7行。
至此,schema HR创建成功!