sqlplus

Config SQL*Plus to return nothing but data

人盡茶涼 提交于 2019-11-30 22:49:46
I need to write a simple shell function that returns a single field from an Oracle DB. Think of it as for example SELECT 'ABC' FROM dual; and ABC is what I am after. Here is my function: function getSomeOraVal { sqlplus $USER/$PASSWD@$ORADB<<!! SET sqlprompt '' SET sqlnumber off SET verify off SET pages 0 SET echo off SET head on SET feedback off SET feed off SET serveroutput on SET escape '\' VARIABLE v_someVal VARCHAR2(30); BEGIN SELECT 'ABC' INTO v_someVal FROM dual; END; / SELECT :v_someVal FROM dual; !! } However, I want to pipe the sqlplus output (data only -> 'ABC') into a shell

Detect sqlplus error in dos batch script?

断了今生、忘了曾经 提交于 2019-11-30 22:13:25
We have the following batch script: ( echo @release.sql echo exit ) | sqlplus x/y@orcl if %errorlevel% gtr 1 goto dberror Issue is - the statement if %errorlevel% gtr 1 never appears to be true when there is a sql error. If we put garbage commands in the release.sql file, sqlplus does complain: SQL> SP2-0042: unknown command "blah" - rest of line ignored. SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production But %errorlevel% still equals 0. How can we determine that there was a sql error? Update : This code DOES appear to work for some sql errors. It

expdp 导出UDE-31623 ORA-31623

穿精又带淫゛_ 提交于 2019-11-30 21:23:46
问题描述: ORACLE EXADATA 12.2 4节点 一个简单的expdp导出,在之前是正常的,但是隔了一天后出现问题了,具体报错信息如下: expdp '"/as sysdba"' DIRECTORY=dir1 DUMPFILE=vat_%U.dmp logfile=vat_20190505.log VERSION= 11.2.0.4.0 SCHEMAS=VAT CLUSTER=NO exclude=STATISTICS parallel=4 UDE-31623: operation generated ORACLE error 31623 ORA-31623: a job is not attached to this session via the specified handle ORA-06512: at "SYS.DBMS_DATAPUMP", line 3326 ORA-06512: at "SYS.DBMS_DATAPUMP", line 4551 ORA-06512: at line 1 解决办法: sqlplus "/ as sysdba SYS@ora122>show parameter streams_pool SYS@ora122>select * from v$sgainfo; #其实为0 SYS@ora122>alter system set

expdp 导出UDE-31623 ORA-31623

白昼怎懂夜的黑 提交于 2019-11-30 21:13:17
问题描述: ORACLE EXADATA 12.2 4节点 一个简单的expdp导出,在之前是正常的,但是隔了一天后出现问题了,具体报错信息如下: expdp '"/as sysdba"' DIRECTORY=dir1 DUMPFILE=vat_%U.dmp logfile=vat_20190505.log VERSION= 11.2.0.4.0 SCHEMAS=VAT CLUSTER=NO exclude=STATISTICS parallel=4 UDE-31623: operation generated ORACLE error 31623 ORA-31623: a job is not attached to this session via the specified handle ORA-06512: at "SYS.DBMS_DATAPUMP", line 3326 ORA-06512: at "SYS.DBMS_DATAPUMP", line 4551 ORA-06512: at line 1 解决办法: sqlplus "/ as sysdba SYS@ora122>show parameter streams_pool SYS@ora122>select * from v$sgainfo; #其实为0 SYS@ora122>alter system set

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

走远了吗. 提交于 2019-11-30 19:58:25
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 this is necessary/ why it chooses to do this? I don't know about the why, but a completely blank line

Oracle数据迁移后归档文件暴增怎么办?

不羁岁月 提交于 2019-11-30 19:14:37
数据迁移是DBA的日常工作,对于相应的方法、命令等,相信很多人早已了如指掌。圆满的数据迁移流程不单单指将数据从数据库A备份恢复到数据库B,而且要保证迁移前后数据的完整性、服务的可用性。 近日,在给客户做了单机到集群的数据迁移后,发现集群的在线重做日志切换频繁,进而产生了大量的归档日志,对服务器造成了不小的压力。本文是对上述问题的分析处理过程。 发现问题 1. 日志归档频繁 在迁移完成后,需要对集群进行一段时间的深度观察。通过v$archived_log视图,分析数据库历史的归档情况,可以发现整个库的业务活动情况。 观察上图,不难发现迁移(6月15日)前后是一个明显得变化点,每天日志归档频率由原来的100多次变成400多次。这种情况要么是迁入的系统业务量确实很大,要么是迁入的数据库用户配置有问题。 2. 业务情况确认 经过与新迁入系统的运维人员沟通确认,该系统的使用人数虽然多,但都是以查询类的动作偏多,不应该带来这么大量的日志。因为集群中还有其它系统,不能直接判断是新系统的问题。假设运维所说情况属实,那么问题的关键点就是要找到产生大量日志的操作语句,进而找到对应的应用,再确认归档情况是否正常。 问题分析 1. 追根溯源 日志归档频繁,说明在线重做日志切换频繁,一般是由于产生了大量的redo。这里通过awr检查redo的生成情况。 一天内日志归档的详细情况

Detect sqlplus error in dos batch script?

送分小仙女□ 提交于 2019-11-30 17:53:44
问题 We have the following batch script: ( echo @release.sql echo exit ) | sqlplus x/y@orcl if %errorlevel% gtr 1 goto dberror Issue is - the statement if %errorlevel% gtr 1 never appears to be true when there is a sql error. If we put garbage commands in the release.sql file, sqlplus does complain: SQL> SP2-0042: unknown command "blah" - rest of line ignored. SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production But %errorlevel% still equals 0. How can we

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

為{幸葍}努か 提交于 2019-11-30 17:30:43
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 CONNECT_DATA What am I missing? I ran the queries suggested by Jakub, I got SQL> select sys_context(

Oracle query execution time

空扰寡人 提交于 2019-11-30 16:53:48
I would like to get the query execution time in Oracle. I don't want the time Oracle needs to print the results - just the execution time. In MySQL it is easy to get the execution time from the shell. How can I do this in SQL*Plus ? Adam Musch One can issue the SQL*Plus command SET TIMING ON to get wall-clock times, but one can't take, for example, fetch time out of that trivially. The AUTOTRACE setting, when used as SET AUTOTRACE TRACEONLY will suppress output, but still perform all of the work to satisfy the query and send the results back to SQL*Plus, which will suppress it. Lastly, one can

Docker操作实践(1):容器的本质是什么?容器从何而来?

邮差的信 提交于 2019-11-30 10:10:22
● 最后启动容器中需要运行的进程Endtrypoint 作者:沈晓龙 其他话题 使用sqlplus进行Oracle数据库批量自动发布 业务复杂、数据庞大、应用广怎办?了解下分布式事务的解决思路! 赣州银行增强科技创新,实现一键灾备切换 SaaS设计:自动化服务启停设计示例 这里有份选择云服务商的攻略,请查收… 来源: https://my.oschina.net/u/4026796/blog/3110183