I am trying to configure the CLIENTS table on my database such that if an employee is deleted from the EMP table any associated clients are automatically deleted from the CLIENTS table.
This is what I've tried so far.
ALTER TABLE clients
MODIFY empno REFERENCES emp(empno) ON DELETE CASCADE
Unfortunately this returns a near "MODIFY": syntax error every time I try to run it. Any idea what is going wrong?
Thanks in advance.
Use this:
ALTER TABLE Clients
ADD CONSTRAINT `Client_1`
FOREIGN KEY empno REFERENCES emp(empno) ON DELETE CASCADE;
UPD:
According to this post , there is no way you can do that in SQLite. Therefore, my suggestion is this:
Of course, if the Clients table is empty right now, you can simply delete it and recreate.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.