sql - 获取 'ORA-00907: missing right parenthesis' ,找不到错误

标签 sql oracle

在 Oracle 中运行脚本后,我收到错误代码“ORA-00907:缺少右括号”。我已经创建了客户表和员工表,它们都运行正确并且添加了正确的表。但是,我在创建“预约”表时遇到问题。创建它的代码如下:

create table Appointment
(appointment_num number(9) not null primary key,
appointment_time datetime(),
emp_ID number(4) not null references employee (emp_ID),
client_ID number(9) not null references client (client_ID))

无法找到错误所在,也无法在其他地方找到该问题的任何故障排除指南。任何帮助将不胜感激。

最佳答案

您有datetime(),请将其更改为date。请注意,datetime 在 Oracle 上是无效数据类型,您需要使用 datetimestamp

create table Appointment
(
  appointment_num number(9) not null primary key,
  appointment_time date,
  emp_ID number(4) not null references employee (emp_ID),
  client_ID number(9) not null references client (client_ID)
)

日期时间戳之间的差异

One of the main problems with the DATE datatype was its' inability to be granular enough to determine which event might have happened first in relation to another event. Oracle has expanded on the DATE datatype and has given us the TIMESTAMP datatype which stores all the information that the DATE datatype stores, but also includes fractional seconds.

Reference

关于sql - 获取 'ORA-00907: missing right parenthesis' ,找不到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54347351/

相关文章:

oracle - 是否可以在列表分区表中自动创建新分区?

java - 将数据插入现有记录

java - Oracle 数据更改通知超时和工作流

php - ORA-24408 : could not generate unique server group name

sql - MS SQL 按状态获取聚合日期时间差异

sql - 使用列的最大值从oracle sql表中过滤行

mysql 根据值将一列分成多列

mysql - sql语句统计记录失败

Mysql:如何正确生成当前一组数字上不存在的唯一10位随机数

php - 如何防止 PHP 中的 SQL 注入(inject)?