帮帮菜鸟:关于在Oracle中插入日期值

[复制链接]
查看11 | 回复4 | 2007-1-19 03:29:30 | 显示全部楼层 |阅读模式
这是我的信息,请各位 大虾帮帮菜鸟,刚接触Oracle,谢谢!
SQL> select * from works;
ID DATE PROJECT
CONTENTPRINCIPALREMARK
W_ID
---------- ---------- ------------------------------ ---------- ---------- -------------------- ----
1 08-12月-04 测试1
标书 Rockyhan 说明文字
1
2 18-9月 -04 测试2
报送资料 QingQing 说明文字2
2
3 18-9月 -99 918
标书 Rockyhan 测试用3
1
4 01-10月-49 The new Nation
其他 Rockyhan 添加测试
2
5 02-11月-49 The new Nation2
其他2Rockeyhan添加测试2
1
6 02-11月-49 The new Nation2
其他2Rockeyhan添加测试2
1
7 02-11月-49 The comedy begin
其他4Rockeyhan悲剧开始了
1
10 11-11月-49 The new Nation5
其他5Rockeyhan5 添加测试5
1
已选择8行。
SQL> update works set date=to_date('2004-1-1','yyyy-mm-dd') where id = 7;
update works set date=to_date('2004-1-1','yyyy-mm-dd') where id = 7

*
ERROR 位于第 1 行:
ORA-01747: 无效的用户.表.列,表.列,或列规格
回复

使用道具 举报

千问 | 2007-1-19 03:29:30 | 显示全部楼层
在SQL Plus中显示的是date=to_date('2004-1-1','yyyy-mm-dd')处出错 我是新手请您帮忙 谢谢!
回复

使用道具 举报

千问 | 2007-1-19 03:29:30 | 显示全部楼层
一般不允许将关键字直接定义为列名,但可以关键词加双引号后再进行定义
试试:set "DATE"=to_date('2004-1-1','yyyy-mm-dd')
回复

使用道具 举报

千问 | 2007-1-19 03:29:30 | 显示全部楼层
ORA-01747 invalid user.table.column, table.column, or column specification
Cause: A column name was specified improperly in the current SQL statement.
Action: Check the statement's syntax, especially references to column names, and retry the statement.
你还是再检查一下列名是否正确,语法没有问题。
SQL> update employees set hire_date=to_date('2004-1-1','yyyy-mm-dd')
2where employee_id=206;
已更新 1 行。
回复

使用道具 举报

千问 | 2007-1-19 03:29:30 | 显示全部楼层
看了你的例子估计列名用了关键字。
可以看一下下面例子:
SQL> connect / as sysdba
已连接。
SQL> create table test_date(date date)
2tablespace users;
create table test_date(date date)

*
ERROR 位于第 1 行:
ORA-00904: : 无效的标识符

SQL> create table test_date("date" date)
2tablespace users;
表已创建。
SQL> insert into test_date
2values(to_date('2004-1-1','yyyy-mm-dd'));
已创建 1 行。
SQL> update test_date
2set date=to_date('2004-1-1','yyyy-mm-dd');
set date=to_date('2004-1-1','yyyy-mm-dd')
*
ERROR 位于第 2 行:
ORA-01747: 无效的用户.表.列,表.列,或列规格

SQL> update test_date
2set "date"=to_date('2004-1-1','yyyy-mm-dd');
已更新 1 行。
SQL> rollback;
回退已完成。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行