Documentos de Académico
Documentos de Profesional
Documentos de Cultura
CAROLINA GORDILLO
ARELLANO
T.S.U en TECNOLOGÍAS DE LA
INFORMACIÓN Y COMUNICACIÓN ÁREA
SISTEMAS INFORMÁTICOS
“PRACTICA TRIGGERS”
Elaborado por:
1
BASE DE DATOS PARA APLICACIONES DOCENTE: M.A. CAROLINA GORDILLO
ARELLANO
ACTIVIDAD 2-2
Instrucciones de la práctica:
De acuerdo a lo visto en clases, realiza un disparador siguiendo la estructura explicada,
puedes utilizar variables o no.
Lo que yo realice en esta práctica, fue crear una nueva tabla para mi primer trigger, a
esta tabla le llame prueba 1, consta de solo 4 campos que son, matricula, nombre,
teléfono y apellidos.
Scrip:
create table Prueba1
(Matrícula int primary key not null,
Nombre varchar (15),
Apellidos Varchar (20),
telefono int (10));
show tables;
select*from Prueba1;
De ahí comencé a formar mi trigger, para eso solo puse la sintaxis que primero era delimitar
y poner un signo, yo puse el signo de peso. Por consiguiente, puse crear y el nombre que es
Trigger1 puse el momento insertado en la tabla (que recién cree) el for each row es para
cada línea (registro), se empiece a insertar a la tabla los campos, matricula, nombre
2
BASE DE DATOS PARA APLICACIONES DOCENTE: M.A. CAROLINA GORDILLO
ARELLANO
apellidos y teléfono. En valor, le puse new punto y los campos, para finalizar puse end y los
mismos signos que puse en el delimiter que fueron el signo de peso.
Scrip:
/*triggers*/
delimiter $$
create trigger Trigger1
after insert on Prueba1
for each row
begin
insert into
Prueba1 (Matrícula, nombre, Apellidos,telefono)
values
(new.Matrícula, new.nombre, new.Apellidos,new.telefono);
end $$
Imagen
3
BASE DE DATOS PARA APLICACIONES DOCENTE: M.A. CAROLINA GORDILLO
ARELLANO
imagen