Cannot install HR schema for Oracle 21c express - oracle

I watched video tutorial at https://www.youtube.com/watch?v=IalqQN09OaA . My Oracle database version
select * from v$version;
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
I download sample at https://github.com/donhuvy/db-sample-schemas/tree/main/human_resources .
Inside Oracle SQL Developer version 22.x , with user system, Run command
# C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
I entered
Input 1: Password for HR: 123456
Input 2: Tablespace: SYSTEM
Input 3: Temporary tablespace: TEMP
Input 4: Password for SYSTEM user: 12345678
Input 5: Log path: C:\
Input 6: Connection string: localhost:1521/xe
My steps
localhost:1521/xe
Error
specify password for HR as parameter 1:
specify default tablespeace for HR as parameter 2:
specify temporary tablespace for HR as parameter 3:
specify password for SYS as parameter 4:
specify log path as parameter 5:
specify connect string as parameter 6:
Error starting at line : 86 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
DROP USER hr CASCADE
Error report -
ORA-01918: user 'HR' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
Error starting at line : 95 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
CREATE USER hr IDENTIFIED BY &pass
Error report -
ORA-65096: invalid common user or role name
65096. 00000 - "invalid common user or role name"
*Cause: An attempt was made to create a common user or role with a name
that was not valid for common users or roles. In addition to the
usual rules for user and role names, common user and role names
must consist only of ASCII characters, and must contain the prefix
specified in common_user_prefix parameter.
*Action: Specify a valid common user or role name.
Error starting at line : 97 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
ALTER USER hr DEFAULT TABLESPACE &tbs
QUOTA UNLIMITED ON &tbs
Error report -
ORA-01918: user 'HR' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
Error starting at line : 100 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
ALTER USER hr TEMPORARY TABLESPACE &ttbs
Error report -
ORA-01918: user 'HR' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
Error starting at line : 102 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
GRANT CREATE SESSION, CREATE VIEW, ALTER SESSION, CREATE SEQUENCE TO hr
Error report -
ORA-01917: user or role 'HR' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line : 103 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
GRANT CREATE SYNONYM, CREATE DATABASE LINK, RESOURCE , UNLIMITED TABLESPACE TO hr
Error report -
ORA-01917: user or role 'HR' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Connected.
Error starting at line : 110 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
GRANT execute ON sys.dbms_stats TO hr
Error report -
ORA-01917: user or role 'HR' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line : 116 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
connect ...
Error report -
Connection Failed
USER = hr
URL = jdbc:oracle:thin:#localhost:1521/xe
Error Message = ORA-01017: invalid username/password; logon denied
Commit
SP2-0640: Not connected
SP2-0640: Not connected
Error starting at line : 124 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_cre
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_cre.sql"
Error starting at line : 130 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_popul
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_popul.sql"
Error starting at line : 136 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_idx
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_idx.sql"
Error starting at line : 142 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_code
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_code.sql"
Error starting at line : 148 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_comnt
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_comnt.sql"
Error starting at line : 154 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_analz
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_analz.sql"
How to fix?
Update
Use command
alter session set "_oracle_script"=true;
# C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
Session altered.
specify password for HR as parameter 1:
specify default tablespeace for HR as parameter 2:
specify temporary tablespace for HR as parameter 3:
specify password for SYS as parameter 4:
specify log path as parameter 5:
specify connect string as parameter 6:
User HR dropped.
User HR created.
User HR altered.
User HR altered.
Grant succeeded.
Grant succeeded.
Connected.
Grant succeeded.
Connected.
Session altered.
Session altered.
Error starting at line : 124 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_cre
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_cre.sql"
Error starting at line : 130 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_popul
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_popul.sql"
Error starting at line : 136 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_idx
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_idx.sql"
Error starting at line : 142 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_code
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_code.sql"
Error starting at line : 148 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_comnt
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_comnt.sql"
Error starting at line : 154 File # C:\Users\Administrator\Downloads\db-sample-schemas-21.1\human_resources\hr_main.sql
In command -
#__SUB__CWD__/human_resources/hr_analz
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_analz.sql"
Connection created by CONNECT script command disconnected
PL/SQL procedure successfully completed.
DBMS_SYSTEM.GET_ENV
Alias sqlcl_int_runme dropped
How to fix error
Error report -
SP2-0310: Unable to open file: "__SUB__CWD__/human_resources/hr_idx.sql"

Unfortunately the default sample script installation process is not great for the novice. Please head over to this blog post
https://connor-mcdonald.com/2021/11/02/quick-and-easy-sample-data/
which describes why this is the case, but more importantly will give you a workaround which involves just running a single script in SQL*Plus. That script will also try to guide you through the process to avoid any errors, eg
| 1) Preliminary checks
| =====================
|
| You should be connected to the database at this point.
| If you are, then you will see the following:
|
| >>> Connected as: YOUR_USER <<<
|
| If you are not, you're will see the following
|
| >>>> SP2-0640: Not connected <<<<
|
| If you get this error, press Ctrl-C to exit this script and
| connect first before running it again.
|
| Tip: For Express Edition, the command to connect is *probably*
|
| SQL> connect system/yourpassword#//localhost/XEPDB1
|
| Once you are connected OK, then press Enter to proceed
|
Connected as: MCDONAC
Enter to proceed, Ctrl-C to stop
|
| Checking that we can write a file to the current directory
| If we can't, then this script will exit here. Please make
| you are running the script from the directory you saved it to
| and this directory is writable
|
File test passed!
|
|
| Now checking database details. If any of these fail,
| the script will exit with the error that you need
| to resolve.
|
Container database. PDB PDB1 will be used for installation...proceeding
|
| Checking current user details
|
You are connected as MCDONAC, ie, not the HR schema.
Hence this installation will drop the HR schema entirely
and recreate it. If this was not what you wanted, then press Ctrl-C
the installation, otherwise press Enter to continue
Enter to proceed, Ctrl-C to stop
|
| Checking required privileges
|
Privilege ALTER ANY TABLE..................OK
Privilege ALTER ANY TRIGGER................OK
Privilege ALTER SESSION....................OK
Privilege ALTER USER.......................OK
Privilege ANALYZE ANY......................OK
Privilege COMMENT ANY TABLE................OK
Privilege CREATE ANY CLUSTER...............OK
Privilege CREATE ANY INDEX.................OK
Privilege CREATE ANY INDEXTYPE.............OK
Privilege CREATE ANY OPERATOR..............OK
Privilege CREATE ANY PROCEDURE.............OK
Privilege CREATE ANY SEQUENCE..............OK
Privilege CREATE ANY SYNONYM...............OK
Privilege CREATE ANY TABLE.................OK
Privilege CREATE ANY TRIGGER...............OK
Privilege CREATE ANY TYPE..................OK
Privilege CREATE ANY VIEW..................OK
Privilege CREATE SESSION...................OK
Privilege CREATE USER......................OK
Privilege DELETE ANY TABLE.................OK
Privilege DROP USER........................OK
Privilege GRANT ANY OBJECT PRIVILEGE.......OK
Privilege GRANT ANY PRIVILEGE..............OK
Privilege INSERT ANY TABLE.................OK
Privilege SELECT ANY TABLE.................OK
Privilege UPDATE ANY TABLE.................OK
Privilege SELECT ON GV$SESSION.............OK
|
| Checking tablespaces
|
Checks .......OK
|
| Checking existing HR details
|
Checks .......OK
|
| The new/replaced HR schema will be created now.
|
| Note down this password for the HR schema. You will need it to connect
|
| Password (case-sensitive): DAjcBlFOJq$986
|
| The script will exit on any error encountered, because it should run
| to completion with no errors at all
|
Press Enter to start
****** Creating REGIONS table ....
Table created.
Index created.
Table altered.
etc etc

Related

Oracle DATAPUMP import failed

I am currently trying to import a database using DBMS_DATAPUMP in PL/SQL using the following script.
DECLARE
h1 NUMBER;
BEGIN
h1 := DBMS_DATAPUMP.OPEN('IMPORT', 'FULL', NULL, DBMS_SCHEDULER.generate_job_name, 'LATEST');
DBMS_DATAPUMP.ADD_FILE(handle => h1, filename => 'EXAMPLE6.DMP', directory => 'DUMP');
DBMS_DATAPUMP.START_JOB(h1);
dbms_datapump.detach(h1);
END;
/
Everytime I execute this code, I get the following error message.
ERROR in line 1:
ORA-39001: invalid argument value
ORA-06512: in "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: in "SYS.DBMS_DATAPUMP", line 4929
ORA-06512: in "SYS.DBMS_DATAPUMP", line 5180
ORA-06512: in line 5
I already googled the error, but the answer mostly consisted of checking if the directory was already created and if the user had read and write access to the directory.
I also tried the impdp tool just as an experiment, to see if I could execute imports that way.
impdp pdb2 directory="DUMP" dumpfile="EXAMPLE6.DMP"
Based on the user I am executing impdp as, I get different error messages.
As a user with all privileges granted:
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-39155: error expanding dump file name "C:\Users\...\EXAMPLE6.DMP"
ORA-48128: opening of a symbolic link is disallowed
As the sysdba user:
ORA-39002: invalid operation
ORA-39070: unable to open the log file
ORA-39087: directory name DUMP is invalid
As I already said, the directory does exist on my drive, I created the directory called DUMP in Oracle and granted read and write access to my user.
All help would be appreciated and I would be happy to clarify if I wrote something confusing!
Edit:
Output of select directory_name, directory_path from dba_directories;
DIRECTORY_NAME
--------------------------------------------------------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
DUMP
C:\Users\Nemanja\Desktop\oraclePLS
I forgot to mention, that the Oracle service has complete access to the specified Windows directory.

ORA-20000: Schema "HR" does not exist or insufficient privileges

I use Oracle 11g express. I try to install sample database HR. From cmd
sqlplus
system
123456
Error:
Comment created.
Commit complete.
BEGIN dbms_stats.gather_schema_stats( 'HR' , granularity => 'ALL' , cascade => TRUE , block_sample => TRUE ); END;
*
ERROR at line 1:
ORA-20000: Schema "HR" does not exist or insufficient privileges
ORA-06512: at "SYS.DBMS_STATS", line 3701
ORA-06512: at "SYS.DBMS_STATS", line 24470
ORA-06512: at "SYS.DBMS_STATS", line 24435
ORA-06512: at line 1
How I install sample database HR correctly?
Apparently the statement to create the user hr was not executed correctly, and despite that the execution of the hr_main.sql script is not stopped.
This worked for me:
Once as sysdba:
SQL> alter session set "_ORACLE_SCRIPT"=true;
Session altered.
SQL> create user hr identified by hr;
User created.
SQL> drop user hr cascade;
User droped.
SQL> #?/demo/schema/human_resources/hr_main.sql
...
User created.
...
Navigate to the PDB container as SYS user before executing the script
[oracle#af18354c958e /]$ sqlplus sys as sysdba
Enter password: password
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> alter session set container = ORCLPDB1
SQL> #hr_main.sql
specify password for HR as parameter 1:
Enter value for 1: hr
specify default tablespeace for HR as parameter 2:
Enter value for 2: users
specify temporary tablespace for HR as parameter 3:
Enter value for 3: temp
specify log path as parameter 4:
Enter value for 4: $ORACLE_HOME/demo/schema/log/
The problem is the line
create user hr identified by 123456a#
Because user is not created, you are getting other errors.
To resolve it do either of below
Remove special character from password. Or use underscores _ in password.
create user hr identified by 123456a
OR
Try enclosing password in double quotes. (I am not able to test it now. But if it doesn't work, try first option. I referred this link)
create user hr identified by "123456a#"

Trouble installing SQL Developer OE (Order Entry) sample database

I've been at this for literally hours. I've followed the instructions here - http://docs.oracle.com/database/121/COMSC/installation.htm#COMSC109 - but I get the following when arriving at the 'Installing Schema OE and Subschema OC' section and doing as it says, running oe_main.sql;
specify password for OE as parameter 1:
old:DEFINE pass = &1
new:DEFINE pass = oe
specify default tablespeace for OE as parameter 2:
old:DEFINE tbs = &2
new:DEFINE tbs = OE
specify temporary tablespace for OE as parameter 3:
old:DEFINE ttbs = &3
new:DEFINE ttbs = temp
specify password for HR as parameter 4:
old:DEFINE passhr = &4
new:DEFINE passhr = hr
specify password for SYS as parameter 5:
old:DEFINE pass_sys = &5
new:DEFINE pass_sys = manager
specify directory path for the data files as parameter 6:
old:DEFINE data_path = &6
new:DEFINE data_path = C:\
writeable directory path for the log files as parameter 7:
old:DEFINE log_path = &7
new:DEFINE log_path = C:\
specify version as parameter 8:
old:DEFINE vrs = &8
new:DEFINE vrs = 5
old:DEFINE spool_file = &log_path.oe_oc_&vrs..log
new:DEFINE spool_file = C:\oe_oc_5.log
old:SPOOL &spool_file
new:SPOOL C:\oe_oc_5.log
Error starting at line : 75 in command -
DROP USER oe CASCADE
Error report -
SQL Error: ORA-01918: user 'OE' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
old:CREATE USER oe IDENTIFIED BY &pass
new:CREATE USER oe IDENTIFIED BY oe
Error starting at line : 86 in command -
CREATE USER oe IDENTIFIED BY oe
Error at Command Line : 86 Column : 30
Error report -
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
old:ALTER USER oe DEFAULT TABLESPACE &tbs QUOTA UNLIMITED ON &tbs
new:ALTER USER oe DEFAULT TABLESPACE temp QUOTA UNLIMITED ON temp
Error starting at line : 88 in command -
ALTER USER oe DEFAULT TABLESPACE &tbs QUOTA UNLIMITED ON &tbs
Error report -
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
old:ALTER USER oe TEMPORARY TABLESPACE &ttbs
new:ALTER USER oe TEMPORARY TABLESPACE temp
Error starting at line : 90 in command -
ALTER USER oe TEMPORARY TABLESPACE &ttbs
Error report -
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
Error starting at line : 92 in command -
GRANT CREATE SESSION, CREATE SYNONYM, CREATE VIEW TO oe
Error report -
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
Error starting at line : 93 in command -
GRANT CREATE DATABASE LINK, ALTER SESSION TO oe
Error report -
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
Error starting at line : 94 in command -
GRANT RESOURCE TO oe
Error report -
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
Error starting at line : 95 in command -
GRANT CREATE MATERIALIZED VIEW TO oe
Error report -
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
Error starting at line : 96 in command -
GRANT QUERY REWRITE TO oe
Error report -
SQL Error: ORA-01031: insufficient privileges
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to perform a database operation without
the necessary privileges.
*Action: Ask your database administrator or designated security
administrator to grant you the necessary privileges
old:CONNECT sys/&pass_sys AS SYSDBA
new:CONNECT sys/manager AS SYSDBA
Connected
Error starting at line : 103 in command -
GRANT execute ON sys.dbms_stats TO oe
Error report -
SQL Error: ORA-01917: user or role 'OE' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
old:CONNECT hr/&passhr
new:CONNECT hr/hr
Connected
Error starting at line : 110 in command -
GRANT REFERENCES, SELECT ON employees TO oe
Error report -
SQL Error: ORA-01917: user or role 'OE' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line : 111 in command -
GRANT REFERENCES, SELECT ON countries TO oe
Error report -
SQL Error: ORA-01917: user or role 'OE' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line : 112 in command -
GRANT REFERENCES, SELECT ON locations TO oe
Error report -
SQL Error: ORA-01917: user or role 'OE' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line : 113 in command -
GRANT SELECT ON jobs TO oe
Error report -
SQL Error: ORA-01917: user or role 'OE' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line : 114 in command -
GRANT SELECT ON job_history TO oe
Error report -
SQL Error: ORA-01917: user or role 'OE' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line : 115 in command -
GRANT SELECT ON departments TO oe
Error report -
SQL Error: ORA-01917: user or role 'OE' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
old:CONNECT oe/&pass
new:CONNECT oe/oe
Error starting at line : 122 in command -
CONNECT oe/&pass
Error report -
Connection Failed
Commit
The problems start with 'User 'OE' doesn't exist'. Any Oracle DBA available for some guidance?
Running this in Oracle SQL Developer, and tried the same in SQLPlus - same results.
EDIT:
Now seeing this;
specify password for OE as parameter 1:
old:DEFINE pass = &1
new:DEFINE pass = oe
specify default tablespeace for OE as parameter 2:
old:DEFINE tbs = &2
new:DEFINE tbs = OE
specify temporary tablespace for OE as parameter 3:
old:DEFINE ttbs = &3
new:DEFINE ttbs = temp
specify password for HR as parameter 4:
old:DEFINE passhr = &4
new:DEFINE passhr = hr
specify password for SYS as parameter 5:
old:DEFINE pass_sys = &5
new:DEFINE pass_sys = password
specify directory path for the data files as parameter 6:
old:DEFINE data_path = &6
new:DEFINE data_path = C:\
writeable directory path for the log files as parameter 7:
old:DEFINE log_path = &7
new:DEFINE log_path = C:\log
specify version as parameter 8:
old:DEFINE vrs = &8
new:DEFINE vrs = v3
old:DEFINE spool_file = &log_path.oe_oc_&vrs..log
new:DEFINE spool_file = C:\logoe_oc_v3.log
old:SPOOL &spool_file
new:SPOOL C:\logoe_oc_v3.log
user OE dropped.
old:CREATE USER oe IDENTIFIED BY &pass
new:CREATE USER oe IDENTIFIED BY oe
user OE created.
old:ALTER USER oe DEFAULT TABLESPACE &tbs QUOTA UNLIMITED ON &tbs
new:ALTER USER oe DEFAULT TABLESPACE OE QUOTA UNLIMITED ON OE
Error starting at line : 96 in command -
ALTER USER oe DEFAULT TABLESPACE &tbs QUOTA UNLIMITED ON &tbs
Error report -
SQL Error: ORA-00959: tablespace 'OE' does not exist
00959. 00000 - "tablespace '%s' does not exist"
*Cause:
*Action:
old:ALTER USER oe TEMPORARY TABLESPACE &ttbs
new:ALTER USER oe TEMPORARY TABLESPACE temp
user OE altered.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
old:CONNECT sys/&pass_sys AS SYSDBA
new:CONNECT sys/password AS SYSDBA
Connected
GRANT succeeded.
old:CONNECT hr/&passhr
new:CONNECT hr/hr
Connected
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
old:CONNECT oe/&pass
new:CONNECT oe/oe
Connected
session SET altered.
session SET altered.
old:DEFINE vscript = ?/demo/schema/order_entry/coe_&vrs
new:DEFINE vscript = ?/demo/schema/order_entry/coe_v3
old:#&vscript &vrs &pass &pass_sys
new:#?/demo/schema/order_entry/coe_v3 v3 oe password
Error starting at line : 139 in command -
#&vscript &vrs &pass &pass_sys
Error report -
Unable to open file: "?/demo/schema/order_entry/coe_v3.sql"
old:DEFINE vscript = ?/demo/schema/order_entry/loe_&vrs
new:DEFINE vscript = ?/demo/schema/order_entry/loe_v3
old:#&vscript &vrs &data_path &log_path &pass
new:#?/demo/schema/order_entry/loe_v3 v3 C:\ C:\log oe
Error starting at line : 146 in command -
#&vscript &vrs &data_path &log_path &pass
Error report -
Unable to open file: "?/demo/schema/order_entry/loe_v3.sql"
old:DEFINE vscript = ?/demo/schema/order_entry/poe_&vrs
new:DEFINE vscript = ?/demo/schema/order_entry/poe_v3
old:#&vscript &vrs
new:#?/demo/schema/order_entry/poe_v3 v3
Error starting at line : 153 in command -
#&vscript &vrs
Error report -
Unable to open file: "?/demo/schema/order_entry/poe_v3.sql"
Error starting at line : 159 in command -
#?/demo/schema/order_entry/oc_main
Error report -
Unable to open file: "?/demo/schema/order_entry/oc_main.sql"
Error starting at line : 165 in command -
#?/demo/schema/order_entry/oe_analz
Error report -
Unable to open file: "?/demo/schema/order_entry/oe_analz.sql"
Connection created by CONNECT script command disconnected
The first error is 'tablespace 'OE' does not exist' - surely the whole point is to create it? And then line above appears to be trying to do that.
There's also errors retrieving the data (Unable to open file) - is that because I specified only C:\ (incidentally when I have this working I'll change that, I just got fed up with copying and pasting the complete path every time)? I've tried specifying C:\app\Hamish\product\11.2.0\dbhome_1\demo\schema\order_entry which is where the data is but I get the same result as above.
EDIT 2:
Now I'm seeing this;
As per my comments to the guys who gave feedback below - am I supposed to put the /demo/... somewhere in the SQL Developer directory so it can automatically find the files?
specify password for OE as parameter 1:
old:DEFINE pass = &1
new:DEFINE pass = oe
specify default tablespeace for OE as parameter 2:
old:DEFINE tbs = &2
new:DEFINE tbs = users
specify temporary tablespace for OE as parameter 3:
old:DEFINE ttbs = &3
new:DEFINE ttbs = temp
specify password for HR as parameter 4:
old:DEFINE passhr = &4
new:DEFINE passhr = hr
specify password for SYS as parameter 5:
old:DEFINE pass_sys = &5
new:DEFINE pass_sys = password
specify directory path for the data files as parameter 6:
old:DEFINE data_path = &6
new:DEFINE data_path = C:/
writeable directory path for the log files as parameter 7:
old:DEFINE log_path = &7
new:DEFINE log_path = C:/log
specify version as parameter 8:
old:DEFINE vrs = &8
new:DEFINE vrs = v3
old:DEFINE spool_file = &log_path.oe_oc_&vrs..log
new:DEFINE spool_file = C:/logoe_oc_v3.log
old:SPOOL &spool_file
new:SPOOL C:/logoe_oc_v3.log
user OE dropped.
old:CREATE USER oe IDENTIFIED BY &pass
new:CREATE USER oe IDENTIFIED BY oe
user OE created.
old:ALTER USER oe DEFAULT TABLESPACE &tbs QUOTA UNLIMITED ON &tbs
new:ALTER USER oe DEFAULT TABLESPACE users QUOTA UNLIMITED ON users
user OE altered.
old:ALTER USER oe TEMPORARY TABLESPACE &ttbs
new:ALTER USER oe TEMPORARY TABLESPACE temp
user OE altered.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
old:CONNECT sys/&pass_sys AS SYSDBA
new:CONNECT sys/password AS SYSDBA
Connected
GRANT succeeded.
old:CONNECT hr/&passhr
new:CONNECT hr/hr
Connected
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
GRANT succeeded.
old:CONNECT oe/&pass
new:CONNECT oe/oe
Connected
session SET altered.
session SET altered.
old:DEFINE vscript = ?/demo/schema/order_entry/coe_&vrs
new:DEFINE vscript = ?/demo/schema/order_entry/coe_v3
old:#&vscript &vrs &pass &pass_sys
new:#?/demo/schema/order_entry/coe_v3 v3 oe password
Error starting at line : 131 in command -
#&vscript &vrs &pass &pass_sys
Error report -
Unable to open file: "?/demo/schema/order_entry/coe_v3.sql"
old:DEFINE vscript = ?/demo/schema/order_entry/loe_&vrs
new:DEFINE vscript = ?/demo/schema/order_entry/loe_v3
old:#&vscript &vrs &data_path &log_path &pass
new:#?/demo/schema/order_entry/loe_v3 v3 C:/ C:/log oe
Error starting at line : 138 in command -
#&vscript &vrs &data_path &log_path &pass
Error report -
Unable to open file: "?/demo/schema/order_entry/loe_v3.sql"
old:DEFINE vscript = ?/demo/schema/order_entry/poe_&vrs
new:DEFINE vscript = ?/demo/schema/order_entry/poe_v3
old:#&vscript &vrs
new:#?/demo/schema/order_entry/poe_v3 v3
Error starting at line : 145 in command -
#&vscript &vrs
Error report -
Unable to open file: "?/demo/schema/order_entry/poe_v3.sql"
Error starting at line : 151 in command -
#?/demo/schema/order_entry/oc_main
Error report -
Unable to open file: "?/demo/schema/order_entry/oc_main.sql"
Error starting at line : 157 in command -
#?/demo/schema/order_entry/oe_analz
Error report -
Unable to open file: "?/demo/schema/order_entry/oe_analz.sql"
Connection created by CONNECT script command disconnected
EDIT 3: I went into each file and manually changed the #? for #C:/[path to..]/demo/schema ... etc. Once it could find the files the process completed but it was painful amending every single #? - if there's an easier way to do this I'd like to hear it.
FYI for anyone struggling with this process going forward (evidently that's not many people as there's very little on the internet about this):
Make sure you're logged in as sys/[sys password]. You can change this via SQLPlus if you're not sure by using sqlplus / as sysdba and then use an ALTER statement to change the password.
Specify for the input: default OE tablespace "users".
Update all the #? to the directory your files are stored.
The output shows a series of ORA-01031: insufficient privileges for activities like CREATE USER. Clearly you are not running this script whilst connected as SYSDBA account.
The script itself states:
rem NOTES
rem Run as SYS or SYSTEM
Note that you need to connect AS SYSDBA. It's better to use an OS account that's part of the DBA group. Check your connection properties in SQL Developer. See this. Or in SQL*Plus you do something like this:
SQL> show user
USER is "APC"
SQL> connect / as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL>
By the way, it's very bad practice to specify the root directory for everything DEFINE data_path = C:\. I hope that's not what you're really doing. Finding files will be an absolute nightmare.
Although this is installation is for 12c, I have found that it does not reckon with that this must be performed against a pluggable database, and not against the container database. It seems it is built for 12C databases that do not use cdb/pdb. To make this work for a pdb you have to:
beforehand connect with sys to the pdb where you want the HR and OE schemas.
Edit the hr_main.sql and oe_main sql lines that do a CONNECT and add #[pdbname] to it. This has to be done for CONNECT with hr, oe and sys
Example: CONNECT oe/&pass has to be changed to CONNECT oe/&pass#[pdb name]

How can I install the sample schemas?

I'm learning Oracle 12c using the book Oracle Database 12c Install, Configure & Maintain Like a Pro. I installed the database, but I didn't find the sample schemas (tables like Customers, Sales, products ...). So I download Oracle Database 12c Release 1 Examples (12.1.0.1.0) for Microsoft Windows (x64) and installed it; but I still don't know how to get the sample tables.
From SQL Developer I ran mksample.sql to install all the sample schemas but I got:
Error starting at line 119 in command:
DROP USER hr CASCADE
SQL Error: ORA-01918: user 'HR' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
Error starting at line 120 in command:
DROP USER oe CASCADE
Error report:
SQL Error: ORA-01918: user 'OE' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
Error starting at line 121 in command:
DROP USER pm CASCADE
Error report:
SQL Error: ORA-01918: user 'PM' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
....
How can I fix this?
update: when i run hr_main.sql I get this after I enter 5 times a password:
specify password for HR as parameter 1:
specify default tablespeace for HR as parameter 2:
specify temporary tablespace for HR as parameter 3:
specify password for SYS as parameter 4:
specify log path as parameter 5:
Error starting at line 63 in command:
DROP USER hr CASCADE
Error report:
SQL Error: ORA-01918: user 'HR' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
Error starting at line 72 in command:
CREATE USER hr IDENTIFIED BY oracle12c
Error at Command Line:72 Column:13
Error report:
SQL Error: ORA-65096: invalid common user or role name
Error starting at line 74 in command:
ALTER USER hr DEFAULT TABLESPACE &tbs
QUOTA UNLIMITED ON &tbs
Error report:
SQL Error: ORA-01918: user 'HR' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
Error starting at line 77 in command:
ALTER USER hr TEMPORARY TABLESPACE &ttbs
Error report:
SQL Error: ORA-01918: user 'HR' does not exist
01918. 00000 - "user '%s' does not exist"
*Cause: User does not exist in the system.
*Action: Verify the user name is correct.
Error starting at line 79 in command:
GRANT CREATE SESSION, CREATE VIEW, ALTER SESSION, CREATE SEQUENCE TO hr
Error report:
SQL Error: ORA-01917: user or role 'HR' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line 80 in command:
GRANT CREATE SYNONYM, CREATE DATABASE LINK, RESOURCE , UNLIMITED TABLESPACE TO hr
Error report:
SQL Error: ORA-01917: user or role 'HR' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Connected
Error starting at line 87 in command:
GRANT execute ON sys.dbms_stats TO hr
Error report:
SQL Error: ORA-01917: user or role 'HR' does not exist
01917. 00000 - "user or role '%s' does not exist"
*Cause: There is not a user or role by that name.
*Action: Re-specify the name.
Error starting at line 93 in command:
CONNECT hr/&pass
Error report:
Connection Failed
Commit

Oracle 11g. Unable to import dump files, even though schema is created

I have created a user in Oracle 11gR2, using the following script
create user cata
identified by cata
default tablespace tbs
temporary tablespace temp;
grant DBA to cata;
After trying to import a dump file using the command
impdp system/password#ORCL11 schemas=cata dumpfile=cata.dmp logfile=log.txt
i'm getting the following error
ORA-39002: invalid operation
ORA-39165: Schema ATGDB_CATA was not found.
Surprisingly, when i try to export a dump from the same schema, i'm able to do that. So, if the schema was not created properly then i should not be able to export the dump file as well, right ?
I have also checked in dba_users & the schema is created. Is there anything else that i can do which could resolve this problem
Out of the error message I guess that the original schema name was "atgdb_cata".
As you are now trying to import into a schema named "cata" you need to specify the parameter remap_schema
So for your case:
impdp system/password#ORCL11 schemas=atgdb_cata dumpfile=cata.dmp logfile=log.txt remap_schema=atgdb_cata:cata
Grant the roles of read and write on the Directory in which you created to the New User: EX:
GRANT READ, WRITE ON DIRECTORY dir_name TO NEW_USER:
Also grant the following role to the new user:
GRANT IMP_FULL_DATABASE TO NEW_USER;
Thanks!
NC
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
SOLUTION:
create or replace directory test_ dir as 'FOLDER_NAME' ;
that 'FOLDER_NAME' must has that dump file
step : 1
create folder SAMPLE under orcle_installed_path/sql/SAMPLE
put that dump file into that SAMPLE folder.
go to bin and execute ./sqlplus
and login
SQL>create or replace directory test_ dir as 'SAMPLE' ;
SQL> SQL> GRANT READ, WRITE on directory test_dir to 'USER';
SQL> GRANT IMP_FULL_DATABASE to 'USER';
exit
then impdb to import that dump

Resources