sqlplus

sqlplus spooling: How to get rid of first, empty line?

孤人 提交于 2019-11-30 08:27:31
I'm doing the following spooling statement: SET VERIFY OFF SET FEEDBACK OFF SET HEADING OFF SET TRIMSPOOL ON SET TERM OFF SPOOL &pathRelations START scripts/relations.sql &parent SPOOL OFF SET TERM ON The scripts/relations.sql file contains a simple select statement. Unfortunately, the spooled file contains an empty line as the first one in the file. This line causes trouble in our framework. Of course I could get rid of these line through sed but ain't there a way to suppress its creation in the first place? Tagar SET NEWPAGE NONE is the correct answer. SET NEWPAGE 0 will cause a page feed,

SQLPlus - spooling to multiple files from PL/SQL blocks

末鹿安然 提交于 2019-11-30 07:39:17
问题 I have a query that returns a lot of data into a CSV file. So much, in fact, that Excel can't open it - there are too many rows. Is there a way to control spool to spool to a new file everytime 65000 rows have been processed? Ideally, I'd like to have my output in files named in sequence, such as large_data_1.csv , large_data_2.csv , large_data_3.csv , etc... I could use dbms_output in a PL/SQL block to control how many rows are output, but then how would I switch files, as spool does not

How do you execute SQL from within a bash script?

为君一笑 提交于 2019-11-30 06:57:19
问题 I have some SQL scripts that I'm trying to automate. In the past I have used SQL*Plus, and called the sqlplus binary manually, from a bash script. However, I'm trying to figure out if there's a way to connect to the DB, and call the script from inside of the bash script... so that I can insert date and make the queries run relative to a certain number of days in the past. 回答1: I'm slightly confused. You should be able to call sqlplus from within the bash script. This may be what you were

how to pass variable from shell script to sqlplus

坚强是说给别人听的谎言 提交于 2019-11-30 05:29:44
I have a shell script that calls file.sql I am looking for a way to pass some parameters to my file.sql. If I don't pass a variable with some value to the sql script, I will have to create multiple .sql files with SELECT statement and all that would change is few words. My shell script calls file.sql: sqlplus -S user/pass@localhost echo " Processing triples" ./load_triples.sh BUILDING/Mapping_File BUILDING Y >> load_semantic.log @/opt/D2RQ/file.sql exit; EOF And this is how my file.sql looks like: SET ECHO ON; SPOOL count.log SELECT COUNT(*) as total_count FROM TABLE(SEM_MATCH( '{ ?s rdf:type

What is the difference between bind variables and the variable which I input using &&?

一个人想着一个人 提交于 2019-11-30 05:23:25
What is the difference between these two variable declarations? 1: num number:='&&num'; 2: variable num1 number; Since in both cases I can reference num by using &num or &&num in other files also, and in the case of bind variables :num1 . Moreover I have one more confusion: whether any of the below statements differ somehow, are they both valid and do they mean the same thing? 1: variable num1 number; 2: var num1 number; You appear to have some confusion about the differences between bind variables in Oracle and substitution variables in SQL*Plus. Let's start with substitution variables.

Why doesn't ORACLE allow consecutive newline characters in commands?

久未见 提交于 2019-11-30 03:59:47
问题 I write: :CREATE TABLE Person ( :name CHAR(10), : :ssn INTEGER); and save it to a file "a.sql" (colon represents beginning of line, is not in actual code.) If I then run it by typing "@a" in the SQL*Plus command prompt, it will tell me that the line starting with "ssn" is not recognized as a command, and is ignored. From what I gather, it seems that sqlplus terminates a command if it encounters multiple newline characters in a row. Is this an accurate statement? If so, does anyone know if

dba 如何直接解决 ORA-28002的问题

谁都会走 提交于 2019-11-30 03:19:54
问题: 登陆,就报口令还有7天就到期了,由于用户太多,有上1000个,能否不修改口令,通过dba统一修改? 下面模拟一下场景: 1.先确定一下环境: db版本: SQL> select * from v$version; BANNER Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production PL/SQL Release 11.2.0.4.0 - Production CORE 11.2.0.4.0 Production TNS for Linux: Version 11.2.0.4.0 - Production NLSRTL Version 11.2.0.4.0 - Production 日期时间: [oracle@dbserver ~]$ date Thu Jan 9 18:03:39 CST 2014 口令到期时间: SQL> select resource_name,limit from dba_profiles where profile='DEFAULT' and RESOURCE_NAME='PASSWORD_LIFE_TIME'; RESOURCE_NAME LIMIT PASSWORD_LIFE_TIME 180 用户状态: SQL> select username,ACCOUNT

How do I exit a script in SQLPlus when an error occurs and return to the SQLPlus prompt, without disconnecting or exiting SQLPlus?

北慕城南 提交于 2019-11-30 02:25:07
I have some scripts that get run often, always from within a connected SQLPlus session. I need a way to exit the script when an error occurs, without disconnecting or exiting SQLPlus itself. 100% of the time, when an error occurs, the connected DBA will need to issue one or more commands into the session. 100% of the time, when an error occurs, there are other SQLPlus statements (and thus must be outside of a BEGIN..END; ) later on in the script that must not be executed or serious problems could arise. NOTE: If you suggest WHENEVER SQLERROR EXIT then you didn't read the above text. That will

SQLPLUS error:ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

时光怂恿深爱的人放手 提交于 2019-11-30 00:42:23
问题 I downloaded SQLPLUS from Oracle: http://www.oracle.com/technetwork/topics/winx64soft-089540.html Basic Lite and SQL*Plus I then fired up SQL*Plus: c:\Program Files\Oracle\instantclient_12_1>sqlplus /nolog SQL*Plus: Release 12.1.0.2.0 Production on Wed Apr 15 15:25:36 2015 Copyright (c) 1982, 2014, Oracle. All rights reserved. and tried to connect to a database: connect user\password@hostname and received the error message: ERROR: ORA-12504: TNS:listener was not given the SERVICE_NAME in

How to install SQL * PLUS client in linux

你说的曾经没有我的故事 提交于 2019-11-30 00:11:16
I am working on AWS services. I have an ec2 ( centos ) instance. I need to configure SQL*Plus client on this centos machine. The server with whom I want to connect is at some remote area. The server version is oracle-se(11.2.0.2) Kindly help me getting the client installed on the centos machine. Thanks in advance. Go to Oracle Linux x86-64 instant clients download page Download the matching client oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm Install rpm -ivh oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm rpm -ivh oracle