5
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SQL*Plusで全体の表示幅とカラムの表示幅を変更する方法

Last updated at Posted at 2020-01-31
  • 環境
    • SQL*Plus: Release 12.2.0.1.0 Production
    • Oracle Database 12c Standard Edition Release 12.2.0.1.0 - 64bit Production

全体の表示幅を変更する方法

set linesize {}
-- 幅を確認する
show linesize

広げてみた

-- 幅が狭くてなんだかわからない
SQL> select tablespace_name,block_size,initial_extent,next_extent,min_extents,max_extents,max_size,pct_increase,min_extlen,status,contents from dba_tablespaces;

TABLESPACE_NAME                BLOCK_SIZE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS
------------------------------ ---------- -------------- ----------- -----------
MAX_EXTENTS   MAX_SIZE PCT_INCREASE MIN_EXTLEN STATUS    CONTENTS
----------- ---------- ------------ ---------- --------- ---------------------
SYSTEM                               8192          65536                       1
 2147483645 2147483645                   65536 ONLINE    PERMANENT
...省略...

-- デフォルトの値を確認する
SQL> show linesize
linesize 80
-- 幅を広げる
SQL> set linesize 200
-- 確認する
SQL> show linesize
linesize 200
-- もう一度検索してみると見やすくなった
SQL> select tablespace_name,block_size,initial_extent,next_extent,min_extents,max_extents,max_size,pct_increase,min_extlen,status,contents from dba_tablespaces;

TABLESPACE_NAME                BLOCK_SIZE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS   MAX_SIZE PCT_INCREASE MIN_EXTLEN STATUS    CONTENTS
------------------------------ ---------- -------------- ----------- ----------- ----------- ---------- ------------ ---------- --------- ---------------------
SYSTEM                               8192          65536                       1  2147483645 2147483645                   65536 ONLINE    PERMANENT
...省略...
6行が選択されました。

カラムの表示幅を変更する方法

参考 : [SQL*Plus] SELECT結果の列幅を指定する | ORACLE逆引きノート

column {カラム名} format a{};

狭めてみた

-- [DIRECTORY_PATH]カラムが広すぎでみずらい
SQL> select * from dba_directories;

OWNER                          DIRECTORY_NAME
------------------------------ ------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SYS                            ORACLE_OCM_CONFIG_DIR
/opt/oracle/product/11.2/state

SYS                            DATA_PUMP_DIR
/opt/oracle/PONSUKE/dpdump/
...省略...
-- 表示幅を狭める
SQL> column directory_path format a60;
-- 見やすくなる
SQL> select * from dba_directories;

OWNER                          DIRECTORY_NAME                 DIRECTORY_PATH
------------------------------ ------------------------------ ------------------------------------------------------------
SYS                            ORACLE_OCM_CONFIG_DIR          /opt/oracle/product/11.2/state
SYS                            DATA_PUMP_DIR                  /opt/oracle/PONSUKE/dpdump/
...省略...
5
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?