clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36282 in the last week).

CREATE TABLE `tic_bd_compus` ( `id` int(10) NOT NULL, `cod_activo` varchar(50) CHARACTER SET utf32 COLLATE utf32_spanish2_ci DEFAULT NULL, `serial` varchar(100) CHARACTER SET utf32 COLLATE utf32_spanish2_ci NOT NULL, `centro_operacion` varchar(100) CHARACTER SET utf32 COLLATE utf32_spanish2_ci DEFAULT NULL, `usuario` varchar(100) CHARACTER SET utf32 COLLATE utf32_spanish2_ci NOT NULL, `procesador` varchar(100) CHARACTER SET utf32 COLLATE utf32_spanish2_ci DEFAULT NULL, `memo_ram` varchar(100) CHARACTER SET utf32 COLLATE utf32_spanish2_ci DEFAULT NULL, `disco_duro` varchar(100) CHARACTER SET utf32 COLLATE utf32_spanish2_ci DEFAULT NULL, `sis_operativo` varchar(100) CHARACTER SET utf32 COLLATE utf32_spanish2_ci DEFAULT NULL, `estado` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1=activo 0=inactivo' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci; INSERT INTO `tic_bd_compus` (`id`, `cod_activo`, `serial`, `centro_operacion`, `usuario`, `procesador`, `memo_ram`, `disco_duro`, `sis_operativo`, `estado`) VALUES (1, '0028886-000', 'GXLD9L2', 'BOGOTA', 'JUAN DIAZ', 'Core i3-6006U', '9182 MB', '500 GB', 'Windows 10 Pro', 1), (2, '0008595-000', 'MXL20208TN', 'BOGOTA', 'PEDRO GOMEZ', 'Core i3-2100', '2048 MB', '465.8 GB', 'Windows 7 Pro', 1), (3, '0015487-000', 'S10036C9', 'MEDELLIN', 'CARLOS JIMENEZ', 'Core i3-4130', '4096 MB', '465.8 GB', 'Windows 10 Pro', 1), (4, '0015499-000', '5CD0157H3P', 'MEDELLIN', 'ANDREA GARCIA', 'Core i5-4500U', '8192 MB', '985 GB', 'Windows 10 Pro', 1), (5, '0009693-000', '5CM3280CSZ', 'CALI', 'MARIA LOPEZ', 'Atom D2550', '4096 MB', '465.8 GB', 'Windows 7 Pro', 1); CREATE TABLE `tic_bd_info` ( `id` int(11) NOT NULL, `serial_compu` varchar(200) COLLATE utf8_bin NOT NULL, `ant_centro` varchar(200) COLLATE utf8_bin NOT NULL, `ant_usuario` varchar(200) COLLATE utf8_bin NOT NULL, `nuevo_centro` varchar(200) COLLATE utf8_bin NOT NULL, `nuevo_usuario` varchar(200) COLLATE utf8_bin NOT NULL, `f_registro` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ALTER TABLE `tic_bd_compus` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `serial` (`serial`), ADD UNIQUE KEY `cod_activo` (`cod_activo`); ALTER TABLE `tic_bd_info` ADD PRIMARY KEY (`id`); ALTER TABLE `tic_bd_compus` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=366; ALTER TABLE `tic_bd_info` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
 hidden batch(es)


CREATE TRIGGER tic_bd_compus_bu BEFORE UPDATE ON tic_bd_compus FOR EACH row BEGIN IF new.centro_operacion <> old.centro_operacion || new.usuario <> old.usuario THEN BEGIN INSERT INTO tic_bd_info ( serial_compu, ant_centro, ant_usuario, nuevo_centro, nuevo_usuario, f_registro) VALUES ( old.serial, old.centro_operacion, old.usuario, new.centro_operacion, new.usuario, NOW()); END; END IF; END
 hidden batch(es)


UPDATE `tic_bd_compus` SET usuario = 'Test' WHERE id = 1; UPDATE `tic_bd_compus` SET procesador = 'Test' WHERE id = 2;
 hidden batch(es)


SELECT * FROM tic_bd_info
id serial_compu ant_centro ant_usuario nuevo_centro nuevo_usuario f_registro
13 GXLD9L2 BOGOTA JUAN DIAZ BOGOTA Test 2021-11-17 00:05:21
 hidden batch(es)