如何以小写形式显示列名? [英] How can I show the column name in lower case?

查看:38
本文介绍了如何以小写形式显示列名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表结构:

SQL>DESCRIBE tipsdb;

 Name                       Null?               Type
 ----------------------------------------- -------- ----------------------------
 USERNAME                                           CHAR(20)

 MAC                                                CHAR(20)

 PASSWORD                                           CHAR(50)

SQL>

完整的表格输出:

SQL> select * from tipsdb;


USERNAME
------------------------------------------------------------

MAC

------------------------------------------------------------

PASSWORD
--------------------------------------------------------------------------------

arun

aabbccddeeff

whopee

当前输出:

SQL> select PASSWORD as user_password from tipsdb;

USER_PASSWORD

--------------------------------------------------------------------------------
whopee

预期输出:

SQL> select PASSWORD as user_password from tipsdb;

user_password
----------------------
whopee

在上面的查询中,我希望 user_password 列以小写而不是大写显示.

In the above query I want the user_password column to be displayed in lower case instead of upper case.

推荐答案

您可以使用 SQL*Plus column 命令覆盖默认标题:

You can use the SQL*Plus column command to override the default heading:

SQL> column username heading "username"
SQL> column password heading "password"
SQL> select username, mac, password from tipsdb

您不必将所需的标题用双引号括起来来指定要使用的大小写,但我认为它是故意的更清楚一些;如果你的标题有多个词,你确实需要引号.

You don't have to enclose the desired heading in double-quotes to specify the case to use, but I think it's a bit clearer that it's intentional; and you do need the quotes if your heading has multiple words.

关于格式化列 在 SQL*Plus 用户指南和参考中.

如果您的查询为列名指定了别名,那么您需要在 column 命令中引用该别名.

If your query specifies an alias for the column name then you need to refer to that alias in the column command.

但您也可以将别名本身设为小写,方法是将其括在双引号中,使其 一个带引号的标识符:

But you can also make the alias itself lower-case, by enclosing that in double quotes, making it a quoted identifier:

SQL> select PASSWORD as "user_password" from tipsdb;

而且因为它被引用,所以你可以使用空格而不是下划线:

And because it's quoted you could use a space instead of an underscore it you wanted to:

SQL> select PASSWORD as "user password" from tipsdb;

然后您就不需要 column 标题设置.引用带引号的标识符通常很麻烦,因为它们必须被引用并且在任何地方都完全相同,但纯粹为了像这样显示可能很有用.

You then don't need a column heading setting. Referring to a quoted identifier is generally a pain as they have to quoted and have exactly the same everywhere, but purely for display like this is can be useful.

这篇关于如何以小写形式显示列名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆