Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I format my oracle queries so the columns don't wrap?

Tags:

oracle

sqlplus

I've tried this, but it doesn't work:

col * format a20000 

Do I really have to list every column specifically? That is a huge pain in the arse.

like image 251
someguy Avatar asked Oct 09 '08 16:10

someguy


People also ask

How do you format in Oracle?

You can change the displayed width of a CHAR, VARCHAR2 (VARCHAR), LONG, DATE, or Trusted Oracle column by using the COLUMN command with a format model consisting of the letter A (for alphanumeric) followed by a number representing the width of the column in characters.

How do I beautify a query in SQL Developer?

How do you format your SQL code in SQL Developer? You can press CTRL+F7 (on Windows) to format the SQL code in your current Code Editor window to update the formatting of the code based on any format changes you have made.

What is column format in SQL?

SQL*Plus COLUMN FORMAT is one of several commands that can alter the appearance of the output. SQL*Plus COLUMN FORMAT does not alter table structures; it only changes the format for the specified column. Normally, SQL*Plus commands, including COLUMN FORMAT, are only effective for the current session of SQL*Plus.

What is set Pagesize in Oracle?

The PAGESIZE setting tells SQL*Plus the number of printed lines that will fit on one page of output.


2 Answers

Never mind, figured it out:

set wrap off set linesize 3000 -- (or to a sufficiently large value to hold your results page) 

Which I found by:

show all 

And looking for some option that seemed relevant.

like image 200
someguy Avatar answered Sep 22 '22 01:09

someguy


I use a generic query I call "dump" (why? I don't know) that looks like this:

SET NEWPAGE NONE SET PAGESIZE 0 SET SPACE 0 SET LINESIZE 16000 SET ECHO OFF SET FEEDBACK OFF SET VERIFY OFF SET HEADING OFF SET TERMOUT OFF SET TRIMOUT ON SET TRIMSPOOL ON SET COLSEP |  spool &1..txt  @@&1  spool off exit 

I then call SQL*Plus passing the actual SQL script I want to run as an argument:

sqlplus -S user/password@database @dump.sql my_real_query.sql 

The result is written to a file

my_real_query.sql.txt

.

like image 37
Patrick Cuff Avatar answered Sep 23 '22 01:09

Patrick Cuff