sqlplus

oracle sql plus spool

纵饮孤独 提交于 2019-12-06 10:52:08
问题 I'm using sql plus to execute a query (a select) and dump the result into a file, using spool option. I have about 14 millions lines, and it takes about 12 minutes to do the dump. I was wondering if there is something to make the dump faster? Here below my sql plus options: whenever sqlerror exit sql.sqlcode set pagesize 0 set linesize 410 SET trimspool ON set heading on set feedback off set echo off set termout off spool file_to_dump_into.txt select * from mytable; Thanks. 回答1: Are you

Export from sql to excel

Deadly 提交于 2019-12-06 04:19:24
I run a query using sqlplus command line interface. The query will fetch some 30 million records. I need to export the result to either csv or xls format. Can anyone let me know if this is possible? Any help is much appreciated. Thanks in advance. Try spool myresults.csv before your select statement, which Excel can easily open. EDIT Like this: SET UNDERLINE OFF SET COLSEP ',' --That's the separator used by excel later to parse the data to columns SET LINES 100 PAGES 100 SET FEEDBACK off --If you don't want column headings in CSV file SET HEADING off Spool ~\myresults.csv --Now the actual

SqlPlus query issue (Package Spec and Body)

拟墨画扇 提交于 2019-12-06 03:29:03
问题 I am trying to get package spec and body from sqlplus by doing so.. select text from all_source where name = 'PACK_JACK' order by line; but I am only getting its body not the spec.. what I have to change to get both of them as one file.. Thank you 回答1: There is a TYPE column in all_source view. The type can have 2 values - 'PACKAGE' and 'PACKAGE BODY'. So to get the spec, select text from all_source where name = 'PACK_JACK' and type = 'PACKAGE' order by line; and to get the body select text

expdp 导出UDE-31623 ORA-31623

扶醉桌前 提交于 2019-12-06 02:50:28
问题描述: 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

redirect plsql error message to a log file when executing it in sqlplus

喜欢而已 提交于 2019-12-05 21:37:55
Need a way to redirect PL/SQL program error message to a log file when executing it in sqlplus. Say the PL/SQL program is named send_2012.sql and it has the following exception block EXCEPTION WHEN NO_DATA_FOUND THEN var_err := 'Data not found. '; WHEN OTHERS THEN var_err := 'Error in ' || $$plsql_unit || ' | ' || SQLERRM || ' | ' || 'Details: ' || DBMS_UTILITY.format_error_backtrace; END; To run the PL/SQL program in a KornShell (ksh) script, I have: sqlplus some_username/'some_password' @some_database \ @/some/directory/send_2012.sql \ $parameter1 $paramenter2 Suppose error occurs when

Equivalent of MySQL's \G in Oracle's SQL*Plus

会有一股神秘感。 提交于 2019-12-05 21:33:05
问题 In Oracle's SQL*Plus, the results of a SELECT are displayed in a tabular manner. Is there a way to display a row in a key-value manner (like MySQL's \G option)? The database I am working on (the schema is not defined by me) has a bunch of columns named e.g. YN_ENABLED (YN = yes no) which are CHAR(1) . So when I do a query I get a result like ID_MYTABLE Y Y Y ------------ - - - 3445 Y N Y So it's not really clear which columns have which values (without having the schema open in another window

Get IP addresses of established connections to Oracle 11

旧城冷巷雨未停 提交于 2019-12-05 16:27:00
During development I found that database have large number of lived connections by: SELECT username, COUNT(*) FROM v$session GROUP BY username; In order to find who actually hold connection I want to get a list of IP addresses. During general web search and reading official docs I build query: SELECT username, seconds_in_wait, machine, port, terminal, program, module, service_name FROM v$session WHERE type = 'USER'; where machine is most important part of select . But unfortunately machine field shows host name known by client OS . Internet full of recommendation to use UTL_INADDR.GET_HOST

Oracle not available ora-01034

送分小仙女□ 提交于 2019-12-05 12:30:10
I am trying to create to connect with oracle sqlplus. When I login with: User: sys as sysdba Pass: It says Connected to an idle instance. And when I try to create a table, it gives the error ORA-01034: Oracle not available Process ID: 0 Session ID: 0 Serial number: 0 Why is it not creating the table? First - and most importantly: Only use the SYS account for DBA work. Never use it for "regular" work (e.g. creating tables) - use a dedicated regular user account for that. Secondly: " connected to an idle instance " means Oracle was not started. So as you are already connected as sysdba (again:

SQLPlus AUTO_INCREMENT Error

旧街凉风 提交于 2019-12-05 11:37:59
When I try and run the following command in SQLPlus: CREATE TABLE Hotel (hotelNo NUMBER(4) NOT NULL AUTO_INCREMENT, hotelName VARCHAR(20) NOT NULL, city VARCHAR(50) NOT NULL, CONSTRAINT hotelNo_pk PRIMARY KEY (hotelNo)); I get the following error: (hotelNo NUMBER(4) NOT NULL AUTO_INCREMENT, * ERROR at line 2: ORA-00907: missing right parenthesis What am I doing wrong? Many will gripe about this not being a standard feature in Oracle, but when it’s as easy as two more commands after your CREATE TABLE command I can’t see any good reason to use fancy SQL on every insert. First let’s create a

PLSQL, SQL*PLUS get current username?

北城以北 提交于 2019-12-05 08:37:24
I know that the show user command return: USER is "SCOTT" But is it possible in a sql query or in a plsql script to only get the username of the current user and store it in a variable? The USER built-in function may be used. DECLARE v VARCHAR2(30); BEGIN v := USER; END; SYS_CONTEXT( 'USERENV', 'CURRENT_USER' ) fnd_profile.value('USERNAME') fnd_profile.value('USER_ID') fnd_flobal.user_id these can be used to get the user details 来源: https://stackoverflow.com/questions/23417522/plsql-sqlplus-get-current-username