Oracle重命名列是否自动选择?

编程入门 行业动态 更新时间:2024-10-24 11:17:20
本文介绍了Oracle重命名列是否自动选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有2个带有以下字段的表.

I have 2 tables with the following fields.

  • AA
  • BB
  • CC
  • DD
  • AA
  • CC
  • EE

查询

Select t1.*, t2.* from table1 t1, join table2 t2 on table1.DD = table2.EE

我的数据列具有以下列名称:

My data columns back with the following column names:

AA, BB, CC, DD, **AA_1**, **CC_1**, EE

我不希望这样的列名.我希望他们在公用(或所有列)的名称中添加表名的前缀.我可以通过以下方式解决此问题:

I don't want the column names like that. I want them to have the table name prefixed in the names of common (or all columns). I could fix this with:

select t1.AA as t1_AA, t1.BB as t1_BB, t1.CC as t1_CC, t1.DD as t1_DD, t2.AA as t2_AA, t2.CC as t2_CC, t2.EE as t2_EEE from table1 t1, inner join table2 t2 on table1.DD = table2.EE

但这意味着到处的每个选择都将增加500行.在oracle中有一种神奇的方法可以做到这一点吗?基本上我想像这样写我的代码

But that means every select everywhere becomes 500 lines longer. Is there a magic way to do this in oracle? Basically I want to write my code like

select t1.* as t1_*, t2.* as t2_* from table1 t1, inner join table2 t2 on table1.DD = table2.EE

但是,那当然是无效的SQL

But of course that is not valid SQL

推荐答案

在Oracle SELECT语法中,当前无法基于某些表达式将列别名分配给多个列.您必须为每个单独的列分配一个别名.

In Oracle SELECT syntax, there is currently no way to assign column aliases to multiple columns based on some expression. You have to assign an alias to each individual column.

更多推荐

Oracle重命名列是否自动选择?

本文发布于:2023-10-16 16:07:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498066.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重命名   Oracle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!