【发布时间】:2016-08-16 04:29:29
【问题描述】:
所以我有一个名为 Timesheet_approved 的表 funtom_timesheet,我需要引用表 funtom_employee(emp ID), timesheet_approved 列的值也不能与 timesheet_emp 列的值相同,这是我到目前为止的代码...
create table Funtom_timesheet
(
timesheet_ID number(3) constraint timesheet_pk primary key,
timesheet_Emp number(3) constraint timesheet_Emp not null constraint timesheet_Emp references funtom_employee,
timesheet_Wc date constraint timesheet_Wc not null,
timesheet_OT number(2) default 0,
timesheet_Approved number(3) constraint timesheet_approved references funtom_employee constraint timesheet_approved unique(timesheet_Approved,timesheet_Emp)
)
;
新代码仍然出错...
create table Funtom_timesheet
(
timesheet_ID number(3) constraint timesheet_pk primary key,
timesheet_Emp number(3) constraint timesheet_Emp not null references funtom_employee(emp_ID),
timesheet_Wc date constraint timesheet_Wc not null,
timesheet_hours number(2),
timesheet_OT number(2) default 0,
timesheet_Approved number(3),
constraint timesheet_approved_uc unique(timesheet_Approved,timesheet_Emp),
constraint timesheet_approved references funtom_employee(emp_ID)
);
【问题讨论】:
-
这与您上一个问题有一些相同的基本错误。你似乎在发明语法而不是following the documentation。我建议您尝试将那里所说的内容应用到此表中,然后查看您的位置。
-
创建了这个但仍然有错误?创建表 Funtom_timesheet ( timesheet_ID number(3) 约束 timesheet_pk 主键, timesheet_Emp number(3) 约束 timesheet_Emp not null 引用 funtom_employee(emp_ID), timesheet_Wc 日期约束 timesheet_Wc not null, timesheet_hours number(2), timesheet_OT number(2) 默认0, timesheet_Approved number(3), 约束timesheet_approved_uc unique(timesheet_Approved,timesheet_Emp), 约束timesheet_approved 引用 funtom_employee(emp_ID) );
-
看起来像是触发器的工作 - 但我不喜欢使用它们。我会确保 UI 只提供有效的填充选项。
-
@TomMaughan - 请编辑您的问题以表明,作为评论阅读并不容易。谢谢。说出您遇到的什么错误也很有帮助。不过,前两个内联约束仍然是错误的,与上一个问题相同。
-
@AlexPoole 抱歉。
标签: sql oracle constraints