73

I have some queries to find out the ddl of some objects from a schema. The result columns I am getting are truncated in the middle of the queries.

How can I increase the width of the column?

I tried with

SET SERVEROUTPUT ON SIZE 1000000;
SET LINESIZE 50000;
set pagesize 50000;
set long 50000;

But I'm still getting the same result.

11 Answers 11

88

I've just used the following command:

SET LIN[ESIZE] 200

(from http://ss64.com/ora/syntax-sqlplus-set.html).

EDIT: For clarity, valid commands are SET LIN 200 or SET LINESIZE 200.

This works fine, but you have to ensure your console window is wide enough. If you're using SQL Plus direct from MS Windows Command Prompt, the console window will automatically wrap the line at whatever the "Screen Buffer Size Width" property is set to, regardless of any SQL Plus LINESIZE specification.

As suggested by @simplyharsh, you can also configure individual columns to display set widths, using COLUMN col_name FORMAT Ax (where x is the desired length, in characters) - this is useful if you have one or two extra large columns and you just wish to show a summary of their values in the console screen.

6
  • 1
    re "If ... SQL Plus direct from MS Windows Command Prompt ..." I found that "set longchunksize 1000" fixed truncation happening at 80 for me on Windows
    – Straff
    Commented Jan 13, 2016 at 1:04
  • 6
    LOL at first I literally entered SET LIN[ESIZE] 200
    – Pluto
    Commented Oct 11, 2018 at 21:05
  • 1
    @Pluto I have amended the answer to clarify this. Thanks.
    – m-smith
    Commented Oct 12, 2018 at 7:55
  • No problem, it just took me a little bit before I realized how dumb a mistake I made. I also didn't read the second part of your answer at first and that was a big help too.
    – Pluto
    Commented Oct 12, 2018 at 21:47
  • But how can one set this as a default preference? Commented Jul 26, 2023 at 13:45
37

This configuration is working for me:

set termout off
set verify off
set trimspool on
set linesize 200
set longchunksize 200000
set long 200000
set pages 0
column txt format a120

The column format definition with the linesize option helped to avoid the truncation at 80 chars.

14

Try this

COLUMN col_name FORMAT A24

where 24 is you width.

2
  • 1
    yeh good, but if I give A70. it prints 70 chars per line. But, I give more than 80, it prints 80 chars only per line :(( Commented Sep 12, 2011 at 8:06
  • 3
    are you sure that isn't your terminal wrapping it? Commented Sep 12, 2011 at 8:53
10

On Linux try these:

set wrap off
set trimout ON
set trimspool on
set serveroutput on
set pagesize 0
set long 20000000
set longchunksize 20000000
set linesize 4000
0
6

Additionally to setting the LINESIZE, as LordScree suggested, you could also specify to output to a file, to overcome the problem with the console width. Here's how I do it:

set linesize 15000;
spool myoutput.txt;
SELECT 
...
spool off;
2

Actually, even that didn't work for me. When I executed "select dbms_metadata.get_ddl('TABLESPACE','TABLESPACE_NAME') from dual;" I again got only the first three lines, but this time each line was padded out to 15,000 characters. I was able to work around this with:

select substr(dbms_metadata.get_ddl('TABLESPACE','LM_THIN_DATA'),80) from dual;
select substr(dbms_metadata.get_ddl('TABLESPACE','LM_THIN_DATA'),160) from dual;
select substr(dbms_metadata.get_ddl('TABLESPACE','LM_THIN_DATA'),240) from dual;

It sure seemed like there ought to be an easier way, but I couldn't seem to find it.

2

What I use:

set long 50000
set linesize 130

col x format a80 word_wrapped;
select dbms_metadata.get_ddl('TABLESPACE','LM_THIN_DATA') x from dual;

Or am I missing something?

2

This worked like a charm for me with a CLOB column:

set long 20000000
set linesize 32767
column YOUR_COLUMN_NAME format a32767
select YOUR_COLUMN_NAME from YOUR_TABLE;
0

None of these suggestions were working for me. I finally found something else I could do - dbms_output.put_line. For example:

SET SERVEROUTPUT ON
begin
for i in (select dbms_metadata.get_ddl('INDEX', index_name, owner) as ddl from all_indexes where owner = 'MYUSER') loop
  dbms_output.put_line(i.ddl);
end loop;
end;
/

Boom. It printed out everything I wanted - no truncating or anything like that. And that works straight in sqlplus - no need to put it in a separate file or anything.

0

If you are using CMD try this: set linesize 100

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 7, 2022 at 3:06
-5

On Windows you may try this:

  • right-click in the sqlplus window
  • select properties ->layout
  • increase screen buffer size width to 1000
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.