Skip to content

Instantly share code, notes, and snippets.

@mattboothman
Created March 7, 2017 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattboothman/5c612b0178d7b4983ce9ff3c3a819ec0 to your computer and use it in GitHub Desktop.
Save mattboothman/5c612b0178d7b4983ce9ff3c3a819ec0 to your computer and use it in GitHub Desktop.
drop table foo;
create table foo (
id int unsigned not null auto_increment primary key,
bar varchar(10) not null
);
insert into foo (bar) values('fluff');
update foo set bar = 'fluff' where id = 1;
update foo set bar = 'bar' where id = 1;
create TRIGGER update_foo before update on foo
for each row
begin
if (NEW.bar != OLD.bar) then signal sqlstate '02123' SET MESSAGE_TEXT = "Cannot update column 'bar' on table 'foo'"; end if;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment