sqlplus

Formatting output of queries in SQLPlus

北城余情 提交于 2019-11-29 10:42:43
I'm working with SQLPlus at the moment and whenever I query the Database, the result is in a complete mess. In other words, it is hard to read. I wonder if anyone knows how to format the output of queries ( columns, tables.. etc) in SQLPlus that is running on Unix server. But, I am accessing the server from my windows. And, Could anyone tell me where I can get SQLPlus for Ubuntu from? Cheers, Okay, start with this in SQL Plus: SET LINESIZE 20000 TRIM ON TRIMSPOOL ON SPOOL output.txt -- run your queries here SPOOL OFF EXIT Also, René Nyffenegger has a whole section dedicated to Beautifying SQL

EXPORT AS INSERT STATEMENTS: But in SQL Plus the line overrides 2500 characters!

别说谁变了你拦得住时间么 提交于 2019-11-29 10:28:28
问题 I have to export an Oracle table as INSERT STATEMENTS. But the INSERT STATEMENTS so generated, override 2500 characters. I am obliged to execute them in SQL Plus, so I receive an error message. This is my Oracle table: CREATE TABLE SAMPLE_TABLE ( C01 VARCHAR2 (5 BYTE) NOT NULL, C02 NUMBER (10) NOT NULL, C03 NUMBER (5) NOT NULL, C04 NUMBER (5) NOT NULL, C05 VARCHAR2 (20 BYTE) NOT NULL, c06 VARCHAR2 (200 BYTE) NOT NULL, c07 VARCHAR2 (200 BYTE) NOT NULL, c08 NUMBER (5) NOT NULL, c09 NUMBER (10)

Oracle Create Table if it does not exist

为君一笑 提交于 2019-11-29 09:58:32
Can anyone point me to the right syntax to use in order to create a table only if it does not currently exist in the database? I'm currently programming a Java GUI in order to connect to Oracle and execute statements on my database and I'm wondering if I would implement this as a Java constraint or a SQLPlus constraint. Normally, it doesn't make a lot of sense to check whether a table exists or not because objects shouldn't be created at runtime and the application should know what objects were created at install time. If this is part of the installation, you should know what objects exist at

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

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

使用sqlplus进行Oracle数据库批量自动发布

十年热恋 提交于 2019-11-29 09:05:26
应用系统的更新发布在企业日常运维中是一件比较常见工作,有文件的备份替换,也会有数据库方面的更新操作。本文介绍如何通过一台装有sqlplus工具的中转机对不同应用的Oracle数据库进行自动化发布。 经常遇到使用PL/SQL图形化工具对Oracle数据库进行相关的更新操作,例如程序包、触发器、存储过程、视图以及表中的数据。如果是单用户对单台数据库更新少量的内容,这个操作还可以接受,如果数据库服务器比较多,并且要切换不同的用户去更新大量的内容,这种方式就会比较低效繁琐,面对这种场景,实现后台自动化更新就很有必要。 如何通过一台sqlplus中转机对不同的Oracle数据库在后台完成更新示意如下: 规范要求 按照上图示意在后台完成数据库的发布更新需要一定的规范支持,简单来讲就是要让sqlplus工具能很明确的获取到以下几点信息: 更新时用什么账号去连接哪台服务器的哪个实例? 账号对应的密码应该如何传递给sqlplus命令? 更新的是程序包、存储过程还是视图? 多个更新之间是否有前后依赖关系? 更新文件的命名规范 通过sqlplus命令去连接Oracle数据库完成一次更新需要账号、密码、Oracle服务器的IP地址、侦听的端口、实例名、更新文件所在的路径,用法如下: 其中账号、IP地址、端口、实例名属于可公开的信息,这一部分内容可以连同更新次序和更新类型一起组织到文件名称中 例如【次序

ORA-12505, TNS:listener does not currently know of SID given in connect des

♀尐吖头ヾ 提交于 2019-11-29 05:11:02
Please kindly help me as I just installed Oracle 11g but cannot connnect using SQL Devloper using the settings below: Username: system Password: mypassword Hostname: localhost Port: 1521 SID: XE Error message: Status : Failure -Test failed: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor I checked on Windows Services: OracleServiceXE: Started OracleXETNSListener: Started I also unable to connect to admin page: **http://localhost:8080/apex/f?p=4950** It says "This page can't be displayed" I also tested

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

北慕城南 提交于 2019-11-29 05:05:02
问题 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; 回答1: You appear to have some confusion about the differences between

SQLPlus - spooling to multiple files from PL/SQL blocks

巧了我就是萌 提交于 2019-11-29 04:46:05
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 seem to be accessible from PL/SQL blocks? (Oracle 10g) UPDATE: I don't have access to the server, so

TNSPING OK but sqlplus gives ORA-12154?

好久不见. 提交于 2019-11-29 03:41:16
I have Oracle 11 running on a Windows server and I'm logged onto the same server trying to use SQL Plus. When I try to connect I get a ORA-12154 even though TNSPING and various other diagnostics look OK. Can anyone suggest why ? Loads of detail below. I can use sqlplus if I use EZCONNECT like this .. sqlplus EST/EST@192.168.10.15/ORCL ... but if I try to connect using TNSNAMES like this ... sqlplus EST/EST@ORCL ... I get ... ORA-12154: TNS:could not resolve the connect identifier specified TNSPING works OK C:\Documents and Settings\user1>tnsping ORCL TNS Ping Utility for 64-bit Windows:

How to use sql*plus in Windows command script to control flow?

你说的曾经没有我的故事 提交于 2019-11-29 03:16:15
问题 I'm trying to use sql*plus to control a small Windows command script. Basically, I want to execute some PL/SQL (perhaps select from a view or table or execute a function) which shows me the status of some rows in the database, and then depending upon the state of the rows, perform some Windows commands. My problem is how to get the results back into the command script. sqlplus user/password@server @script.sql IF <CONDITIONAL HERE BASED on script.sql results> GOTO :runprocess REM log and email