为什么在Oracle SQL中选择指定的列以及所有错误? [英] Why is selecting specified columns, and all, wrong in Oracle SQL?

查看:95
本文介绍了为什么在Oracle SQL中选择指定的列以及所有错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一条选择语句.

select * from animals

这给出了表中所有列的查询结果.

That gives a a query result of all the columns in the table.

现在,如果表animals的第42列是is_parent,并且我想在结果中返回该值,就在gender之后,这样我就可以更轻松地看到它.但我也希望其他所有列.

Now, if the 42nd column of the table animals is is_parent, and I want to return that in my results, just after gender, so I can see it more easily. But I also want all the other columns.

select is_parent, * from animals

这将返回ORA-00936: missing expression.

同一条语句在Sybase中可以正常工作,而且我知道您需要向animals表中添加表别名才能使其正常工作(select is_parent, a.* from animals ani),但是为什么必须Oracle需要表别名才能进行选择吗?

The same statement will work fine in Sybase, and I know that you need to add a table alias to the animals table to get it to work ( select is_parent, a.* from animals ani), but why must Oracle need a table alias to be able to work out the select?

推荐答案

实际上,解决原始问题很容易.您只需要限定*.

Actually, it's easy to solve the original problem. You just have to qualify the *.

select is_parent, animals.* from animals;

应该可以正常工作.表名的别名也可以使用.

should work just fine. Aliases for the table names also work.

这篇关于为什么在Oracle SQL中选择指定的列以及所有错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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