创建表格约束混淆语法

时间:2016-04-22 18:09:46

标签: sql oracle relational-database sqlplus

创建一个名为funtom_payroll的表,但我需要写一个约束来显示工资单的输入日期,这是在payroll_date中

create table Funtom_payroll
(
 payroll_ID    number(3),
 payroll_Emp      number(3),
 payroll_Standard   number(8,2),
 payroll_Overtime   number(8,2),
 payroll_Pension      number(8,2),
 payroll_Timesheet   number(3),
 payroll_Date      date,
 constraint payroll_pk primary key(payroll_ID),
 constraint payroll_fk1 foreign key (payroll_Emp)
   references funtom_employee(Emp_ID),
 constraint payroll_fk2 foreign key (payroll_Timesheet)
   references funtom_Timesheet( timesheet_id),
"    CODE FOR HERE   "
 );

1 个答案:

答案 0 :(得分:0)

正如Kenney所说,这与Automatically populate date in oracle table非常接近,只有DATE而不是TIMESTAMP

你只需要添加"默认的sysdate"到CREATE声明......这里不需要约束。 PAYROLL_DATE DATE DEFAULT SYSDATE,