Trouble installing SQL Developer OE (Order Entry) sample database - oracle

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]

Related

Cannot install HR schema for Oracle 21c express

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

Oracle 12c sales_history sample schema installation

I am installing sample schema for oracle 12c (12.2). the hr schema installed fine but the sales_order and the other schema are failing.
The failure is only happening for the pluggable database, especially at
specify connect string as parameter 8:
Enter value for 8: sys/password#techfuturepdb as sysdba*
Before running the sample schema script
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 TECHFUTUREPDB READ WRITE NO
What is the connect string? What value is it expecting? My tnsnames.ora file is below
-- Installing sample schema sales_history
SQL> #?/demo/schema/sales_history/sh_main.sql
specify password for SH as parameter 1:
Enter value for 1: password
specify default tablespace for SH as parameter 2:
Enter value for 2: users
specify temporary tablespace for SH as parameter 3:
Enter value for 3: temp
specify password for SYS as parameter 4:
Enter value for 4: password
specify directory path for the data files as parameter 5:
Enter value for 5: /u01/app/oracle/product/12.2/db_1/demo/schema/sales_history
writeable directory path for the log files as parameter 6:
Enter value for 6: /u01/app/oracle/product/12.2/db_1/demo/schema/log
specify version as parameter 7:
Enter value for 7: v3
specify connect string as parameter 8:
Enter value for 8: sys/password#techfuturepdb as sysdba
Session altered.
DROP USER sh CASCADE
*
ERROR at line 1:
ORA-01918: user 'SH' does not exist
old 1: CREATE USER sh IDENTIFIED BY &pass
new 1: CREATE USER sh IDENTIFIED BY password
User created.
old 1: ALTER USER sh DEFAULT TABLESPACE &tbs
new 1: ALTER USER sh DEFAULT TABLESPACE users
old 2: QUOTA UNLIMITED ON &tbs
new 2: QUOTA UNLIMITED ON users
User altered.
old 1: ALTER USER sh TEMPORARY TABLESPACE &ttbs
new 1: ALTER USER sh TEMPORARY TABLESPACE temp
User altered.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Warning: You are no longer connected to ORACLE.
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0640: Not connected
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
SP2-0640: Not connected
SP2-0640: Not connected
SP2-0310: unable to open file "__SUB__CWD__/sales_history/csh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/lsh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/psh_v3.sql"
SQL>
here is my tnsnames.ora file
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
TECHFUTURE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = cisnet-10.elom.tg)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = techfuture.elom.tg)
)
)
LISTENER_TECHFUTURE =
(ADDRESS = (PROTOCOL = TCP)(HOST = cisnet-10.elom.tg)(PORT = 1522))
TECHFUTUREPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = cisnet-10.elom.tg)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TECHFUTUREPDB)
)
)
According to section 2.3 the README file in the GitHub distribution:
Verify the connect string for the database. For illustration
purposes, the value of for database pdb is:
connect_string: localhost:1521/pdb
The connect_string may also be a valid tnsnames.ora entry.
So you only need to give it the TNS alias:
specify connect string as parameter 8:
Enter value for 8: techfuturepdb
or if you prefer the EasyConnect equivalent:
specify connect string as parameter 8:
Enter value for 8: cisnet-10.elom.tg:1522/techfuturepdb
I found the other mistake, which could be a reason for this
SP2-0310: unable to open file "__SUB__CWD__/sales_history/csh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/lsh_v3.sql"
SP2-0310: unable to open file "__SUB__CWD__/sales_history/psh_v3.sql"
Which is
writeable directory path for the log files as parameter 6:
Enter value for 6: /u01/app/oracle/product/12.2/db_1/demo/schema/log
Solution: There needs to be forward-slash after log, like this:
/u01/app/oracle/product/12.2/db_1/demo/schema/log/
It is mentioned in the installation documentation:
https://docs.oracle.com/database/121/COMSC/installation.htm#COMSC001
Enter the directory path, for example, $ORACLE_HOME/demo/schema/log/, for your log directory:

Configuring Oracle XStream

I'm trying to configure Oracle XStream out by official documentation
So, shortly, I'm connecting as sysdba
sqlplus / as sysdba
Then executing commands create create CDB user and give him privileges
> CREATE TABLESPACE xstream_tbs DATAFILE '$ORACLE/cdb/orcl/xstream_tbs.dbf' SIZE 25M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
> CREATE USER c##xstrmadmin IDENTIFIED BY password DEFAULT TABLESPACE xstream_tbs QUOTA UNLIMITED ON xstream_tbs container=all;
> GRANT CREATE SESSION, SET CONTAINER TO c##xstrmadmin CONTAINER=ALL;
After this step I should give permissions to user to use XStream
> BEGIN
DBMS_XSTREAM_AUTH.GRANT_ADMIN_PRIVILEGE(
grantee => 'c##xstrmadmin',
privilege_type => 'CAPTURE',
grant_select_privileges => TRUE,
container => 'ALL');
END;
/
On this stage, I'm getting this error:
ERROR at line 1:
ORA-44001: invalid schema
ORA-06512: at "SYS.DBMS_XSTREAM_AUTH_IVK", line 3383
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_XSTREAM_AUTH_IVK", line 3500
ORA-06512: at "SYS.DBMS_XSTREAM_AUTH", line 34
ORA-06512: at line 2
Current container is cdb$root
Googling gives actually nothing and I have no idea whats wrong as I'm following DBA documentation.
I guess I found workaround.
If you connect to oracle with
> sqlplus /nolog
And then connect as sysdba
> conn / as sysdba
Then all works fine!
If this is only one way to resolve problem with creating permissions then problem is in sqlplus or oracle itself. Sad!

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#"

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

Resources