Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display table data more clearly in oracle sqlplus

I want to be able to display the resulting data from a select in a pretty way, not all columns under others.

Here is the way sqlplus displays my table data:

enter image description here

But I want to show them as:

Name   |    Address    |    Phone    | -------+---------------+-------------+ name1  |    address1   |    phone1   | name2  |    address2   |    phone2   | name3  |    address3   |    phone3   | 

Not each column under the other

like image 858
Nubkadiya Avatar asked Jun 09 '10 13:06

Nubkadiya


People also ask

How do I set the page size in SQL Plus?

At the SQL*Plus command line, type: set pagesize 30 - this will change the page size to 30 rows. set pause on - this will cause the output to pause every 30 lines; press the enter key to continue.

Does Oracle View improve performance?

To summarize, Oracle views are an encapsulation of a complex query and must be used with care. Here are the key facts to remember: Views are not intended to improve SQL performance. When you need to encapsulate SQL, you should place it inside a stored procedure rather than use a view.


2 Answers

I usually start with something like:

set lines 256 set trimout on set tab off 

Have a look at help set if you have the help information installed. And then select name,address rather than select * if you really only want those two columns.

like image 160
Alex Poole Avatar answered Sep 27 '22 17:09

Alex Poole


If you mean you want to see them like this:

WORKPLACEID NAME       ADDRESS        TELEPHONE ----------- ---------- -------------- ---------           1 HSBC       Nugegoda Road      43434           2 HNB Bank   Colombo Road      223423 

then in SQL Plus you can set the column widths like this (for example):

column name format a10 column address format a20 column telephone format 999999999 

You can also specify the line size and page size if necessary like this:

set linesize 100 pagesize 50 

You do this by typing those commands into SQL Plus before running the query. Or you can put these commands and the query into a script file e.g. myscript.sql and run that. For example:

column name format a10 column address format a20 column telephone format 999999999  select name, address, telephone from mytable; 
like image 29
Tony Andrews Avatar answered Sep 27 '22 16:09

Tony Andrews