创建用于设置工资和奖金范围的数据域。
这是表格:
CREATE TABLE Departments (
Dept_ID INT (6) NOT NULL,
Dept_NAME VARCHAR (6) NOT NULL,
DeptHead_ID INT (6) NULL,
DeptAA VARCHAR (6),
ParentDept_ID INT (4) NULL,
Location VARCHAR (4) NOT NULL,
DeptType VARCHAR (6),
Primary key (Dept_ID)
);
CREATE TABLE Employee (
Emp_ID INT (6) NOT NULL,
Name VARCHAR (6) NOT NULL,
Dept_ID INT (6) NOT NULL,
Tax_ID INT (4) NOT NULL,
Country VARCHAR (4) NOT NULL,
Hire_Date DATE,
Birth_Date DATE,
Salary INT (6),
Bonus INT (6),
AddressInfo VARCHAR (6),
Salary INT (6),
(salary > 0)
and (mod(salary, 10) = 0)
and (bonus =< Salary)
PRIMARY KEY(Emp_ID)
FOREIGN KEY(Dept_ID) REFERENCES Departments(Dept_ID)
);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to
use near '(salary > 0) and
(mod(salary, 10) =0)
and (bonus =< Salary),
PRIMARY KEY(Emp_ID' at line 13
数据域和错误的约束:
ALTER TABLE Employee
ADD CONSTRAINT ck_Employee_Salary_dmn
CHECK ((salary > 0)
and
(mod(salary, 10) = 0)
and
(bonus =< Salary)
);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=< Salary))' at line 7
如果我可以提供更多信息,请告诉我。