SQL Server Change column name in Oracle in SELECT statement

kpbpu008  于 2023-03-28  发布在  Oracle
关注(0)|答案(2)|浏览(201)

In MSSQL, I can select a column and change the column header by doing:

SELECT mycolumn as 'MyNewColumnName' from MyTable

This doesn't work in Oracle Database. How do I perform the same thing in Oracle Database?

y4ekin9u

y4ekin9u1#

  1. Remove single quotation marks
SELECT mycolumn as MyNewColumnName 
  from MyTable
  1. Enclose alias in double quotation marks
SELECT mycolumn as "MyNewColumnName" 
  from MyTable
dfty9e19

dfty9e192#

In Oracle you can just provide a space after the column name and provide the alias name without any quotes as

SELECT mycolumn MyNewColumnName from MyTable

相关问题