ITPub博客

首页 > 数据库 > Oracle > 向数据库中添加HR用户和SCOTT用户

向数据库中添加HR用户和SCOTT用户

原创 Oracle 作者:TaihangMeng 时间:2016-04-02 22:19:42 0 删除 编辑

一、HR用户的添加

1、查看$ORACLE_HOME/demo/schema/human_resources目录下是否有以下几个SQL执行文件:

hr_analz.sql  
hr_code.sql  
hr_comnt.sql  
hr_cre.sql  
hr_dn_c.sql  
hr_dn_d.sql  
hr_drop.sql  
hr_idx.sql  
hr_main.sql  
hr_popul.sql


  1. [oracle@TaylonMeng ~]$ cd /oracle/product/11.2.0/demo/schema/human_resources
  2. [oracle@TaylonMeng human_resources]$ ls
  3. hr_code.sql

我发现只有一个hr_code.sql文件,然后在网上下载了human_resources,将解压文件放在/oracle/product/11.2.0/demo/schema/human_resources下。

2、执行主脚本文件hr_main.sql,该脚本会调用其他脚本。


  1. [oracle@TaylonMeng ~]$ sqlplus / as sysdba

  2. SQL*Plus: Release 11.2.0.4.0 Production on Sat Apr 2 20:38:56 2016

  3. Copyright (c) 1982, 2013, Oracle. All rights reserved.


  4. Connected to:
  5. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  6. With the Partitioning, OLAP, Data Mining and Real Application Testing options

  7. SQL> @/oracle/product/11.2.0/demo/schema/human_resources/hr_main.sql

  8. specify password for HR as parameter 1:
  9. Enter value for 1: hr

  10. specify default tablespeace for HR as parameter 2:
  11. Enter value for 2: users

  12. specify temporary tablespace for HR as parameter 3:
  13. Enter value for 3: temp

  14. specify password for SYS as parameter 4:
  15. Enter value for 4: password

  16. specify log path as parameter 5:
  17. Enter value for 5: /oralog/hr/

3、检查安装情况


  1. SQL> conn / as sysdba
  2. Connected.
  3. SQL> select username from dba_users;


    USERNAME
    ------------------------------
    SYS
    SYSTEM
    SCOTT
    HR
    OUTLN
    APPQOSSYS
    DBSNMP
    WMSYS
    DIP
    ORACLE_OCM


    10 rows selected.


    SQL> conn hr/hr
    Connected.
    SQL> select table_name from user_tables;


    TABLE_NAME
    ------------------------------
    COUNTRIES
    JOB_HISTORY
    EMPLOYEES
    JOBS
    DEPARTMENTS
    LOCATIONS
    REGIONS


    7 rows selected.


  4. SQL> select EMPLOYEE_ID,HIRE_DATE,SALARY from EMPLOYEES where EMPLOYEE_ID='124';


    EMPLOYEE_ID HIRE_DATE              SALARY
    ----------- ------------------ ----------
            124 16-NOV-99                5800


    1 row selected.


二、SCOTT用户的添加

执行SQL文件存放路径:$ORACLE_HOME/rdbms/admin/utlsampl.sql
执行时需要使用system账户。
  1. [oracle@TaylonMeng admin]$ cd $ORACLE_HOME/rdbms/admin
  2. [oracle@TaylonMeng admin]$ ls utlsampl.sql
  3. utlsampl.sql
  4. [oracle@TaylonMeng admin]$ sqlplus / as sysdba


    SQL*Plus: Release 11.2.0.4.0 Production on Sat Apr 2 22:13:24 2016


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




    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options


    SQL> conn system/*****
    Connected.
    SQL> @$ORACLE_HOME/rdbms/admin/utlsampl.sql
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@TaylonMeng admin]$ sqlplus / as sysdba


    SQL*Plus: Release 11.2.0.4.0 Production on Sat Apr 2 22:14:19 2016


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




    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options


    SQL> select username from dba_users;


    USERNAME
    ------------------------------
    SYS
    SYSTEM
    SCOTT
    HR
    OUTLN
    APPQOSSYS
    DBSNMP
    WMSYS
    DIP
    ORACLE_OCM


    10 rows selected.


    SQL> conn SCOTT/tiger
    Connected.
    SQL> select table_name from user_tables;


    TABLE_NAME
    ------------------------------
    SALGRADE
    BONUS
    EMP
    DEPT










来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30776559/viewspace-2074356/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2016-01-07

  • 博文量
    101
  • 访问量
    147082