sqlplus

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

◇◆丶佛笑我妖孽 提交于 2019-12-04 02:50:56
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). Not built in to SQL PLus, but Tom Kyte has provided a procedure called print_table that does this.

Config SQL*Plus to return nothing but data

空扰寡人 提交于 2019-12-03 21:10:12
问题 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

Execute SQL from batch file

£可爱£侵袭症+ 提交于 2019-12-03 20:27:52
问题 I'm new to batch files scripting. All I want is creating a batch file that calling SQL file and store results in text file . Can anyone help me, your help is highly appreciated, This is the first time I need to create such files. 回答1: using a batch file: save and run this: @echo off sqlplus -s -l user/pass@yourdb @yoursql.sql>your_log.log p.s. be sure to have the last line of your sql script as exit; or the batch file will hang. 回答2: sqlcmd -S sqlservername -i yoursqlfile.sql -U username -P

sqlplus stuck on delete query

我只是一个虾纸丫 提交于 2019-12-03 20:13:52
I'm experiencing a strange issue while using a an anonymous PL/SQL block launched by SQL*Plus. This block contains a delete statement and it works as expected if launched by the oracle sql developer interface. It gets stuck if I launch it from the cmd through sqlplus. I discovered the delete statement is the problem... I have the same situation with a simpler code like that: set serveroutput on size 1000000 begin DELETE FROM USER_LEAD; dbms_output.put_line('test'); end; / exit; If I remove the delete statement everything works and it's the same with my real anonymous block. I want to point out

want to run multiple SQL script file in one go with in SQLPLUS

风流意气都作罢 提交于 2019-12-03 17:50:06
问题 I have to run multiple SQL script file in one go. Like every time i have to write command in SQLPLUS SQL>@d:\a.txt SQL>@d:\a2.txt SQL>@d:\a3.txt SQL>@d:\a4.txt is there any way put all file in one folder & run all script file in one go without missing any single file like @d:\final.txt or @d\final.bat 回答1: There is no single SQL*Plus command to do that, but you can create a single script that calls all the others: Put the following into a batch file @echo off echo.>"%~dp0all.sql" for %%i in (

Explanation of a BLOB and a CLOB

血红的双手。 提交于 2019-12-03 17:37:11
问题 I am looking for a real good explanation of a BLOB and CLOB data. I am looking for the great of that explains in plain English. 回答1: BLOB's (Binary Large OBject) store binary files: pictures, text, audio files, word documents, etc. Anything you can't read with the human eye. You can't select them via SQL*Plus. CLOB's (Character Large OBjects) store character data. They are often used to store XML docs, JSON's or just large blocks of formatted or unformatted text. 回答2: It's pretty straight

Dumping CLOB fields into files?

↘锁芯ラ 提交于 2019-12-03 17:10:52
Say you have the table: Column_name | data_type Title | Varchar2 Text | CLOB with some rows: SomeUnkownMovie | A long time ago in a galaxy far, far away....(long text ahead) FredMercuryBio | Awesomeness and stuff....(more long text) Is there a way I could query that so it outputs files like SomeUnkownMovie.txt FredMercuryBio.txt (and ofc, with their respective texts inside) I reckon this should be a easy enough sqlplus script.. though I'm just not the one :( thanks! LukStorms This pl/sql code should work in oracle 11g. It dumps the text of the clobs into a directory with the title as filename.

Why do i get #### in the NUMBER column after format… Oracle?

怎甘沉沦 提交于 2019-12-03 17:07:11
问题 I have two problematic columns: Fee NUMBER type, AdjFee also NUMBER. After column Fee format a5; select Fee ID smth from Visit; i get Fee ID smth #### 123 klkl #### 654 rfjgr 回答1: You can adjust the number of digits you want SQL*Plus to use to display the numeric data just as you adjust the number of characters used to display character data. Something like column fee format 999999999.99 will tell SQL*Plus to display up to 9 digits before the decimal point and two after the decimal point. You

Default value for paramteters not passed SQLPlus script

百般思念 提交于 2019-12-03 16:36:29
问题 Is there a way to set default value of paramter in sqlplus script without user input? For example, I have an SQL script sessions.sql: SET VERIFY OFF SET TERMOUT OFF DEFINE uname = '&1' COLUMN search_uname new_value search_uname SELECT CASE WHEN '&uname' = '' THEN '%' ELSE UPPER('&uname') END AS search_uname FROM dual; SET TERMOUT ON SELECT sid, serial, username FROM v$session WHERE username LIKE '&search_uname'; And I want to invoke it from sqlplus like this: SQL> @sessions Enter value for 1:

Is it possible for Oracle sqlldr to accept a TNS entry as an instance qualifier in Oracle 10 and 11?

六月ゝ 毕业季﹏ 提交于 2019-12-03 12:40:24
Is it possible to use a fully qualified TNS entry using sqlldr bundled with Oracle 10/11? For example, in SQLPlus: sqlplus user/password@(description=(address=(host=localhost)(protocol=tcp)(port=1521))(connect_data=(sid=orcl))) @script.sql But using sqlldr (SQL Loader) there appear to be issues with using the TNS entry directly. Specifically: sqlldr user/password@(description=(address=(host=localhost)(protocol=tcp)(port=1521))(connect_data=(sid=orcl))) bad='bad_file.txt' control='control.ctl' data='data.txt' log='log.txt' direct='true' Here is the error message produced: LRM-00116: syntax