向資料庫中新增HR使用者和SCOTT使用者

TaihangMeng發表於2016-04-02

一、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部落格 ” ,連結:http://blog.itpub.net/30776559/viewspace-2074356/,如需轉載,請註明出處,否則將追究法律責任。

相關文章