我正在尝试执行.sql脚本或从SQL>提示符查询到多个实例。
但是我无法以这种方式执行它。
<project>
...
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/>
</parent>
<properties>
...
<java.version>11.0.2</java.version>
<maven.compiler.source>11.0.2</maven.compiler.source>
<maven.compiler.target>11.0.2</maven.compiler.target>
<jsoup.version>1.7.3</jsoup.version>
...
</properties>
<dependencies>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- exclusion of tomcat because of jetty -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.3.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.1.5.RELEASE</version>
<!--<version>${spring.version}</version>-->
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.1.Final</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
...
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
</dependencies>
<configuration>
<jvmArguments>
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
</jvmArguments>
</configuration>
</plugin>
...
</plugins>
</build>
<profiles>
<!-- tomcat - default -->
<profile>
<id>tomcat</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
</dependencies>
</profile>
...
</profiles>
</project>
当然,我还有其他一些方法可以完成任务,如下所示:
SQL> conn username/password@REMOTE @sqlscript.sql
OR
SQL> conn username/password@REMOTE @select name from v$database;
但是我正在寻找不同的方式,请在下面的执行中查找 SQL> 提示的错误:
M:\> echo select d.name, p.profile, p.limit from dba_profiles p, v$database d where resource_name = 'PASSWORD_VERIFY_FUNCTION' and profile in ('USERS','SERVICEACCOUNTS'); | sqlplus username/password#77@remotestring
它应该给出查询输出。
答案 0 :(得分:1)
创建环境变量SQLPATH
例如。 Windows
C:\sql>echo %SQLPATH%
c:\sql
创建文件c:\sql\login.sql
set linesize 10000
select name from v$database;
@@init.sql
创建文件c:\sql\init.sql
select sysdate from dual;
测试
C:\sql>sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 4 22:41:52 2019
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SP2-0640: Not connected
SP2-0640: Not connected
SQL> conn system/manager
Connected.
NAME
---------
ORCL
SYSDATE
---------
04-APR-19
SQL> conn system/manager@ORCL
Connected.
NAME
---------
ORCL
SYSDATE
---------
04-APR-19
SQL>