所以我试图这样做,但似乎最后一行(支票)不允许其中的子查询.任何方式使这项工作Oracle?
CREATE TABLE Tank (
n_id int,
day date,
level int,
CONSTRAINT pk_w_td PRIMARY KEY (n_id,day),
CONSTRAINT fk_w_td_tan FOREIGN KEY (n_id) REFERENCES Tanks ON DELETE CASCADE,
CHECK (level > 0 AND level <= (SELECT capacity FROM Tanks WHERE Tanks.n_id = TanksDay.n_id))
);
这是错误信息:
Error at Command Line:7 Column:32 Error report: SQL Error: ORA-02251: subquery not allowed here
02251. 00000 - "subquery not allowed here"
*Cause: Subquery is not allowed here in the statement.
*Action: Remove the subquery from the statement.