SQL check when creating a table
Is it possible to have a CHECK under the form:
CREATE TABLE abc (no INTEGER, det INTEGER NOT NULL,
quo INTEGER CHECK (quo < AVG(st.quo)),
qoh INTEGER CHECK (qoh >= 0));
开发者_Python百科
So basically every time new values are entered to check the average of quo of another (existing) table in the database and if and only if it's lower than the average of that table to allow new data to be inserted in the table?
No. If you want that kind of check, you will have to write a trigger.
You need to do that in a trigger.
精彩评论