Created
December 14, 2013 15:03
-
-
Save HiroNakamura/7960278 to your computer and use it in GitHub Desktop.
Ejemplo de bitácora en MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Autor: Codemonkeyjunior | |
//fecha: 14 de diciembre de 2013 | |
create table persona (id_persona int auto_increment primary key, nombre varchar (50), apellido_p varchar (50), apellido_m varchar(50), edad int, peso double, talla double); | |
CREATE TABLE infobase (usuario varchar (50), descripcion varchar (50),fecha TIMESTAMP default now()); | |
delimiter // | |
create procedure insertar(in nombre varchar(45),apellido_p varchar(45),apellido_m varchar(45),edad int, peso double,talla double) | |
begin | |
insert into persona(nombre,apellido_p,apellido_m,edad,peso,talla) values(nombre,apellido_p,apellido_m,edad,peso,talla); | |
end | |
// | |
delimiter // | |
create procedure actualizar(in idx int, edadx int,pesox double) | |
begin | |
update persona set edad=edadx, peso=pesox where id=idx; | |
end | |
// | |
delimiter // | |
create procedure borrar(in idx int) | |
begin | |
delete from persona where id=idx; | |
end | |
// | |
create trigger tr_insercion before insert on persona | |
for each row | |
insert into infobase(usuario,descripcion,fecha) values (user(),"persona creada",now()); | |
// | |
create trigger tr_actualizacion | |
before update on persona | |
for each row | |
insert into infobase(usuario,descripcion,fecha) values (user(),"persona actualizada",now()); | |
// | |
create trigger tr_borrado before delete on persona | |
for each row | |
insert into infobase(usuario,descripcion,fecha) values (user(),"persona borrada",now()); | |
// | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment