插入语句出错

insert statment make error

我正在使用带有用户名系统的 oracle 12c。我的问题是当我执行从 oracle live sql site:

获取的插入语句时
insert into emp 
values(7788, 'SCOTT', 'ANALYST', 7566,to_date('13-JUL-87','dd-mm-rr') - 85,3000, null, 20); 

显示:

sql error ora-01858. 00000 -  "a non-numeric character was found where a numeric was expected"
*Cause:    The input data to be converted using a date format model was
           incorrect.  The input data did not contain a number where a number was
           required by the format model.
*Action:   Fix the input data or the date format model to make sure the
           elements match in number and type.  Then retry the operation.

to_date(..)

之后的 -85 是什么

要处理日期,最好使用 ANSI 格式 (date 'yyyy-mm-dd'):

insert into emp values(7788, 'SCOTT', 'ANALYST', 7566, date '1987-07-13'- 85,3000, null, 20); 

如果出于某种原因需要使用 to_date,则必须确保字符串的格式与您使用的格式掩码完全匹配:如果您的月份写为 'JUL'您需要在格式掩码中使用 'MON' 而不是 'mm''mm' 将匹配写为 '07'.

的月份

请注意,即使使用正确的格式掩码,这种写日期的方式也很危险,因为它基于您的数据库的语言。

-85表示"subtract 85 days"。