oracle hr建立语句,ORACLE之通过脚本创建schema HR的过程

本文详细记录了在Oracle 11g环境中创建HR schema的过程,包括缺少脚本的解决方法和执行各步骤的SQL命令。通过下载并运行一系列脚本,如hr_main.sql,成功创建了HR用户及其相关的表和对象。最后,验证了HR用户已成功创建,并能正常连接和查看表。
摘要由CSDN通过智能技术生成

今天做实验的时候,老师用到,了HR用户,但是不幸的是老师用的10g,我用的是11g,我的竟然没有该用户:

SQL> select username from dba_users where username='HR';

未选定行

最后通过查找各方资料,终于搞定了,把整个过程记录下来和大家分享

a4c26d1e5885305701be709a3d33442f.png

创建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创建成功!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值