Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text wrapping in oracle

how can we wrap a text (coulmn value) basing ona stndard length of lets say 40 characters in to multi line in ORACLE SQL only.

like image 244
Venkataramesh Kommoju Avatar asked Sep 08 '25 17:09

Venkataramesh Kommoju


2 Answers

select regexp_replace(column_name, '(.{40})', '\1' || chr(10) || chr(13))
from some_table;
like image 77
Lev Khomich Avatar answered Sep 10 '25 06:09

Lev Khomich


In SQL Plus you can assign column widths

column column_name format a40 
select column_name from table_name

The above format the output to be 40 columns wide and it would wrap anything to the next line.

Output display is usually controlled by the client

like image 25
Michael Ballent Avatar answered Sep 10 '25 05:09

Michael Ballent