use sandbox;

drop table if exists tup2jad;

create table tup2jad as select * from Jadralec; #tu so važne velike in male črke

alter table tup2jad add primary key(jid); -- sicer ne dela update v safe mode ker jid ni ključ

drop table if exists tup2log;

create table tup2log (id int primary key NOT NULL AUTO_INCREMENT, opis varchar(100), timestamp date);

DELIMITER //

create TRIGGER tup2tr after update on tup2jad

for each ROW

BEGIN

if old.ime<>new.ime THEN

     insert into tup2log (opis, timestamp) values(concat("sprememba imena iz ", old.ime, " v ", new.ime), now());

    END if;

END//

DELIMITER ;

#to deluje šele potem, ko se trigger ustvari, torej v naslednjem koraku izvajanja SQL

update tup2jad set ime="test" where jid=22;

select * from tup2log;


Zadnja sprememba: torek, 5. december 2023, 16.09