简体   繁体   中英

Rename column name from a values function

When you execute a command like the following

db2 "select count(IBMREQD) from sysibm.sysdummy1"

You can rename the name of the column like

db2 "select count(IBMREQD) qty from sysibm.sysdummy1"

I would like to know if it is possible to rename the columns of a result set returned by values, like the following:

db2 "values varchar(current path)"

To something like:

db2 "values varchar(current path) current_Path"

You can only assign aliases to columns in the SELECT clause of a subselect, and the VALUES statement is in itself a sort of subselect, so you cannot modify what it does. You have to wrap VALUES in another SELECT statement, for example

select * from table( values varchar(current path)) as t( current_Path )

which is basically the same as

select varchar(current path) as current_Path from sysibm.sysdummy1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM