Oracle 18XE 读取文件 hr_main.sql 时出错

问题描述 投票:0回答:1

А创建用户并给予他所有授权后,我在读取文件时出错。哪里出错了?

hr_main.sql
rem
rem Header: hr_main.sql 2015/03/19 10:23:26 smtaylor Exp $
rem
rem Copyright (c) 2001, 2016, Oracle and/or its affiliates. 
rem All rights reserved.
rem 
rem Permission is hereby granted, free of charge, to any person obtaining
rem a copy of this software and associated documentation files (the
rem "Software"), to deal in the Software without restriction, including
rem without limitation the rights to use, copy, modify, merge, publish,
rem distribute, sublicense, and/or sell copies of the Software, and to
rem permit persons to whom the Software is furnished to do so, subject to
rem the following conditions:
rem 
rem The above copyright notice and this permission notice shall be
rem included in all copies or substantial portions of the Software.
rem 
rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
rem EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
rem MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
rem NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
rem LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
rem OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
rem WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
rem
rem Owner  : ahunold
rem
rem NAME
rem   hr_main.sql - Main script for HR schema
rem
rem DESCRIPTON
rem   HR (Human Resources) is the smallest and most simple one 
rem   of the Sample Schemas
rem   
rem NOTES
rem   Run as SYS or SYSTEM
rem
rem MODIFIED   (MM/DD/YY)
rem   celsbern  03/10/16 - removing grant to sys.dbms_stats
rem   dmatisha  10/09/15 - added check to see if hr user exists 
rem       before dropping the hr user.
rem   dmatisha  10/08/15 - removed connect string, sys password, 
rem       changed to use alter session current_schema=hr instead
rem       of reconnecting. You now MUST be connected as sys 
rem       prior to running this script. Modified log parameter 
rem       from &log_path.hr_main.log to &log_path/hr_main.log 
rem   smtaylor  03/19/15 - added parameter 6, connect_string
rem   smtaylor  03/19/15 - added @&connect_string to CONNECT
rem   jmadduku  02/18/11 - Grant Unlimited Tablespace priv with RESOURCE
rem   celsbern  06/17/10 - fixing bug 9733839
rem   pthornto  07/16/04 - obsolete 'connect' role 
rem   hyeh      08/29/02 - hyeh_mv_comschema_to_rdbms
rem   ahunold   08/28/01 - roles
rem   ahunold   07/13/01 - NLS Territory
rem   ahunold   04/13/01 - parameter 5, notes, spool
rem   ahunold   03/29/01 - spool
rem   ahunold   03/12/01 - prompts
rem   ahunold   03/07/01 - hr_analz.sql
rem   ahunold   03/03/01 - HR simplification, REGIONS table
rem   ngreenbe  06/01/00 - created

SET ECHO OFF
SET VERIFY OFF

PROMPT 
PROMPT specify password for C##HR as parameter 1:
DEFINE pass     = &1
PROMPT 
PROMPT specify default tablespeace for C##HR as parameter 2:
DEFINE tbs      = &2
PROMPT 
PROMPT specify temporary tablespace for C##HR as parameter 3:
DEFINE ttbs     = &3
PROMPT 
PROMPT specify log path as parameter 4:
DEFINE log_path = &4
PROMPT

DEFINE spool_file = &log_path/hr_main.log
SPOOL &spool_file

REM =======================================================
REM cleanup section
REM =======================================================

DECLARE
vcount INTEGER :=0;
BEGIN
select count(1) into vcount from dba_users where username = 'C##HR';
IF vcount != 0 THEN
EXECUTE IMMEDIATE ('DROP USER hr CASCADE');
END IF;
END;
/

REM =======================================================
REM create user
REM three separate commands, so the create user command 
REM will succeed regardless of the existence of the 
REM DEMO and TEMP tablespaces 
REM =======================================================

CREATE USER C##hr IDENTIFIED BY &pass;

ALTER USER C##hr DEFAULT TABLESPACE &tbs
              QUOTA UNLIMITED ON &tbs;

ALTER USER C##hr TEMPORARY TABLESPACE &ttbs;

GRANT CREATE SESSION, CREATE VIEW, ALTER SESSION, CREATE SEQUENCE TO C##hr;
GRANT CREATE SYNONYM, CREATE DATABASE LINK, RESOURCE , UNLIMITED TABLESPACE TO C##hr;

REM =======================================================
REM create C##hr schema objects
REM =======================================================

ALTER SESSION SET CURRENT_SCHEMA=C##HR;

ALTER SESSION SET NLS_LANGUAGE=American;
ALTER SESSION SET NLS_TERRITORY=America;

--
-- create tables, sequences and constraint
--

@M:/Oracle18c/demo/schema/human_resources/hr_cre.sql

-- 
-- populate tables
--

@M:/Oracle18c/demo/schema/human_resources/hr_popul.sql

--
-- create indexes
--

@M:/Oracle18c/demo/schema/human_resources/hr_idx.sql

--
-- create procedural objects
--

@M:/Oracle18c/demo/schema/human_resources/hr_code.sql

--
-- add comments to tables and columns
--

@M:/Oracle18c/demo/schema/human_resources/hr_comnt.sql

--
-- gather schema statistics
--

@M:/Oracle18c/demo/schema/human_resources/hr_analz.sql

spool off

我想,我以为数据库会在不编辑的情况下运行文件,但我必须注册一个带有 C## 前缀的用户。 好的,我在文件中添加 C##HR。 比我读取文件错误。我尝试写入sql文件的完整路径,但总是出现读取文件错误

HR_主日志:

PL/SQL procedure successfully completed


User created


User altered


User altered


Grant succeeded


Grant succeeded


Session altered


Session altered


Session altered

Error reading file
Error reading file
Error reading file
Error reading file
Error reading file
Error reading file

sql oracle plsql oracle-sqldeveloper oracle18c
1个回答
0
投票

Oracle 数据库示例架构 github 存储库包含安装说明:

  1. 转到示例模式的最新(或适当)版本并下载源代码 (zip) 文件。
  2. 解压下载的.zip 文件。
  3. 在示例模式主目录中,导航到要安装并运行的示例模式目录 _install.sql 脚本。 (有关更多信息 安装模式,请参阅模式目录中的 README.md 文件。)
  4. 在安装结束时或在生成的安装日志文件中查看安装验证。

如果您按照安装说明进行操作,那么您会发现已发布的存档中没有

hr_main.sql
脚本(您想使用
hr_install.sql
),并且您不需要修改文件来更改任何目录(它们应该可以工作”开箱即用”)。

© www.soinside.com 2019 - 2024. All rights reserved.