ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Formatted SELECT * FROM 'table' Statement Results[akadia]

Formatted SELECT * FROM 'table' Statement Results[akadia]

原创 Linux操作系统 作者:jlandzpa 时间:2019-03-23 20:30:06 0 删除 编辑

This tip comes from Anirban Das, a Senior IA from Vernon Hills, IL. We have improved the SQL statement in some points, so WHERE clauses will be correctly executed.

In SQL*Plus, it is often difficult to read the results of a SELECT *FROM 'table' statement since the output could wrap across multiple lines. For example, the normal output of SELECT * FROM 'dba_users' would be :

USERNAME USER_ID PASSWORD
------------------------------ ---------- ---------
ACCOUNT_STATUS LOCK_DATE EXPIRY_DAT
-------------------------------- ---------- ----------
DEFAULT_TABLESPACE TEMPORARY_TABLESPACE CREATED
------------------------------ --------------------------- -------
PROFILE
------------------------------
EXTERNAL_NAME
------------------------------------------------------------------
SYS 0 5638228DAF52805F
OPEN
SYSTEM TEMP 28-AUG-00

The results are not clearly readable.

Implementing this SQL script, the output would be :

ACCOUNT_STATUS = ----------------OPEN [4]
CREATED = -----------------------08/28/2000 14:56:08 [9]
DEFAULT_TABLESPACE = ------------SYSTEM [6]
EXPIRY_DATE = -------------------[0]
EXTERNAL_NAME = -----------------[0]
LOCK_DATE = ---------------------[0]
PASSWORD = ----------------------5638228DAF52805F [16]
PROFILE = -----------------------DEFAULT [7]
TEMPORARY_TABLESPACE = ----------TEMP [4]
USERNAME = ----------------------SYS [3]
USER_ID = -----------------------0 [1]

This formats the results to 1 row per screen with the length of data in square braces [ ]. It also allows optional WHERE clause and ORDER BY .

Click here for the improved script.


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/936/viewspace-60579/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2001-10-12

  • 博文量
    240
  • 访问量
    172954