“日期”作为列名称 [英] "date" as a column name

查看:169
本文介绍了“日期”作为列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为日历的表。

I have a table called calendars.

其中一个列名为date。

One of its columns is named 'date'

我想选择日期列,它给出错误ORA-01747即无效的table.column。

When I want to select the date column it gives error ORA-01747 namely invalid table.column.

select date from calendars

我想这是因为'date'是pl / sql的保留字。问题是,甚至不能更改列名称:

I guess this happens because 'date' is a reserved word for pl/sql. The problem is it's not even possible to change the column name :

alter table calendars rename column date to date_d

结果是:ORA-00904错误:无效的标识符。

Result is: ORA-00904 error: invalid identifier.

感谢。

推荐答案

select calendars.date from calendars; /* or you could alias "calendars" if you don't want to type so much */

如果这不工作或帮助,你尝试删除列(也许尝试引用它与表名前缀: calendars.date )?

If that doesn't work or help, have you tried dropping the column (and maybe try referencing it with the table name prefix: calendars.date)?

我也发现这个帖子:

I also found this post: How do I escape a reserved word in oracle

似乎Oracle会区分大小写如果您使用双引号,则

It seems that Oracle will be case-sensitive if you use double quotes so

select "date" from calendars;

select "Date" from calendars;

这篇关于“日期”作为列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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