dml
I tried to delete a target that still had findings The database refused That was the foreign key doing its job
insert
INSERT INTO targets (host, port, severity) VALUES
('alpha.local', 22, 'low'),
('beta.local', 443, 'high'),
('gamma.local', 8080, 'medium');
One statement, three rows List the columns explicitly Positional inserts break when someone adds a column
update
UPDATE targets SET severity = 'critical' WHERE host = 'beta.local';
Always check the WHERE
An UPDATE without one rewrites the whole table
That is not a trick question, it is the most common expensive mistake
delete
DELETE FROM findings WHERE target_id = 1;
DELETE FROM targets WHERE host = 'alpha.local';
Children first, parent second
The first statement is required when the foreign key is enforced
The error message says FOREIGN KEY constraint failed
Read it as a warning, not an obstacle
Next
Reading rows in 04 select
Posted