domingo, 22 de junio de 2014

PRACTICA PROCEDIMIENTOS

mysql> create database taller;
Query OK, 1 row affected (0.19 sec)

mysql> use taller;
Database changed
mysql> create table alumnos(cvealumno varchar(30) primary key, nombre varchar(50), apaterno varchar(50), amaterno varcha
r(50), calle varchar(150), numero int, colonia varchar(50), municipio varchar(50), estado varchar(50), telefono varchar(
20), email varchar(10));
Query OK, 0 rows affected (0.33 sec)
mysql> create table profesores(cveprofesor varchar(50) primary key, nombre varchar(50), apaterno varchar(50), amaterno v
archar(50), calle varchar(150), numero int, colonia varchar(50), municipio varchar(50), estado varchar(50), telefono var
char(20), epecialidad varchar(150), email varchar(100));
Query OK, 0 rows affected (0.09 sec)
mysql> create table materias(cvemateria varchar(20) primary key, nombre varchar(50), semestre char);
Query OK, 0 rows affected (0.11 sec)
mysql> create table calificaciones(cveAlumno varchar(30) primary key, eveMateria varchar(50), par1 double, par2 double, par3 double, par4 double, par5 double, p
ar6 double, par7 double, par8 double, par9 double, calificacionFinal double, periodo varchar(20));
Query OK, 0 rows affected (0.11 sec)

mysql> create table carreras( eveCarrera varchar(20) primary key, nombre varchar(50));
Query OK, 0 rows affected (0.04 sec)

mysql> create table grupos(eveGrupo varchar(50) primary key, nombre varchar(50), eveProfesor varchar(50), eveAlumno varchar(50), eveMateria varchar(50), eveCarr
era varchar(50), periodo varchar(20));
Query OK, 0 rows affected (0.07 sec)

mysql>


mysql> delimiter //
mysql> create procedure agregar_alumnos(in cvealumno varchar(30), nombre varchar(50), apaterno varchar(50), amaterno var
char(50), calle varchar(150), numero int, colonia varchar(50), municipio varchar(50), estado varchar(50), telefono varch
ar(20), email varchar(100)) begin insert into alumnos values(cvealumno, nombre, apaterno, amaterno, calle, numero, colon
ia, municipio, estado, telefono, email);
    -> end
    -> //
Query OK, 0 rows affected (0.12 sec)
mysql> create procedure agregar_profesor(in cveprofesor varchar(50), nombre varchar(50), apaterno varchar(50), amaterno
varchar(50), calle varchar(150), numero int, colonia varchar(50), municipio varchar(50), estado varchar(50), telefono va
rchar(20), especialidad varchar(150), email varchar(100)) begin insert into profesores values(cvprofesor, nombre, apater
no, amaterno, calle, numero, colonia, municipio, estado, telefono, especialidad, email);
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> create procedure agregar_materia(in cvemateria varchar(50), nombre varchar(50), semestre char) begin insert into
materias values(cvemateria, nombnre, semestre);
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> create procedure agregar_calificaciones(in cveAlumno varchar(30), cveMateria varchar(50), par1 double, par2 doubl
e, par3 double, par4 double, par5 double, par6 double, par7 double, par8 double, par9 double, calificacionfinal double,p
eriodo varchar(20))
    -> begin
    -> insert into calificaciones values (cveAlumno, cveMateria, par1, par2, pa3, par4, par5, par6, par7, par8, par9, ca
lificacionfinal, periodo);
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> create procedure agregar_carrera(in cveCarrera varchar(20), nombre varchar(50))
    -> begin
    -> insert into carreras values(cveCarrera, nombre);
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> create procedure agregar_grupo(in cveGrupo varchar(50), nombre varchar(50), cveProfesor varchar(50), cveAlumno va
rchar(50), cveMateria varchar(50), cveCarrera varchar(50), periodo varchar(20))
    -> begin
    -> insert into grupos values(cveGrupo, nombre, cveProfesores, cveAlumno, cveMateria, cveCarrera, periodo);
    -> end;
    -> //
Query OK, 0 rows affected (0.06 sec)
Procedimientos de update
mysql> create procedure editar_alumno(in cvealumno varchar(30), nombre varchar(50), apaterno varchar(50), amaterno varch
ar(50), calle varchar(150), numero int, colonia varchar(50), municipio varchar(50), estado varchar(50), telefono varchar
(20), email varchar(100)) begin update alumnos set cvealumno= cvealumno, nombre= nombre, apaterno=apaterno, amaterno= am
aterno, calle=calle, numero=numero, colonia=colonia, municipio=municipio, estado=estado, telefono=telefono, email=email;

    -> end;
    -> //
Query OK, 0 rows affected (0.01 sec)
mysql> create procedure editar_profesor(in cveprofesor varchar(50), nombre varchar(50), apaterno varchar(50), amaterno v
archar(50), calle varchar(150), numero int, colonia varchar(50), municipio varchar(50), estado varchar(50), telefono var
char(20), especialidad varchar(150), email varchar(100)) begin update profesores set cveprofesor=cveprofesor, nombre=nom
bre, apaterno=apaterno, amaterno=amaterno, calle=calle,  numero=numero, colonia=colonia, municipio=municipio, estado=est
ado, telefono=telefono, especialidad=especialidad, email=email;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)
mysql> create procedure editar_materia(in cvemateria varchar(50), nombre varchar(50), semestre char) begin update materi
as set cvemateria=cvemateria, nombre=nombre, semestre=semestre;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)
mysql> create procedure editar_calificacion(in cveAlumno varchar(30), cveMateria varchar(50), par1 double, par2 double,
par3 double, par4 double, par5 double, par6 double, par7 double, par8 double, par9 double, calificacionfinal double, per
iodo varchar(20))
    -> begin
    -> update calificaciones set cveAlumno=cveAlumno, cveMateria=cveMateria, par1=par1, par2=par2, par3=par3, par4=par4,
 par5=par5, par6=par6, par7=par7, par8=par8, par9=par9, calificacionfinal=calificacionfinal, periodo=periodo;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)
mysql> create procedure editar_carrera(in cvecarrera varchar(20), nombre varchar(50))
    -> begin
    -> update carreras set cveCarera=cveCarrera, nombre=nombre;
    -> end;
    -> //
Query OK, 0 rows affected (0.01 sec)

mysql> create procedure editar_grupo(in cveGrupo varchar(50), nombre varchar(50), cveProfesor varchar(50), cveAlumno var
char(50), cveMateria varchar(50), cveCarrera varchar(50), periodo varchar(20))
    -> begin
    -> update grupos set cveGrupo=cveGrupo, nombre=nombre, cveProfesor=cveProfesor, cveAlumno=cveAlumno, cveMateria=cveM
ateria, cveCarrera=cveCarrera, periodo=periodo;
    -> end;
    -> //
Query OK, 0 rows affected (0.05 sec)
Procedimientos de eliminar

mysql> create procedure eliminar_alumno(in cvealumno varchar(30)) begin delete from alumnos where cvealumno=alumno;
    -> end;
    -> //
Query OK, 0 rows affected (0.12 sec)

mysql> create procedure eliminar_profesor(in cveprofesor varchar(50)) begin delete from profesores where cveprofesor=cveprofesor;
    -> end;
    -> //
Query OK, 0 rows affected (0.12 sec)
mysql> create procedure eliminar_materia(in cvemateria varchar(50)) begin delete from materias where cvemateria=cvemateria;
    -> end;
    -> //
Query OK, 0 rows affected (0.12 sec)
mysql> create procedure eliminar_calificacion(in cveAlumno varchar(30))
    -> begin
    -> delete from calificaciones where cveAlumno=cveAlumno;
    -> end;
    -> //
Query OK, 0 rows affected (0.01 sec)

mysql> create procedure eliminar_grupo(in cveGrupo varchar(50))
    -> begin
    -> delete from grupos where cveGrupo=cveGrupo;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)
mysql> create procedure eliminar_carrera(in cveCarrera varchar(30))
    -> begin
    -> delete from carrera where cveCarrera=cveCarrera;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)
Procedimientos de vistas

mysql> create procedure ver_alumno()
    -> begin
    -> select * from alumnos;
    -> end;
    -> //
Query OK, 0 rows affected (0.03 sec)

mysql> create procedure ver_profesor()
    -> begin
    -> select * from profesores;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)
mysql> create procedure ver_materia()
    -> begin
    -> select * from materias;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)
mysql> create procedure ver_calificacion()
    -> begin
    -> select * from calificaciones;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> create procedure ver_grupo()
    -> begin
    -> select * from grupos;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)


mysql> create procedure ver_carrera()
    -> begin
    -> select * from carreras;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql>


TRABAJO: EVALUACIÓN DE PROCEDIMIENTOS

PROCEDIMIENTOS BD MERCOSUR

PROCEDIMIENTOS TABLE:  PAIS
AGREAR
mysql> use mercosur;
Database changed
mysql> delimiter //
mysql> create procedure agregar_pais(in codigo_exportacion integer(11), codigo_producto integer(11), codigo_pais integer(11), nombre_pais varchar(50))

    -> begin
    -> insert into pais values (codigo_exportacion, codigo_producto, codigo_pais, nombre_pais);
    -> select * from pais;
    -> end;
    -> //
Query OK, 0 rows affected (0.04 sec)

mysql> call agregar_pais(11,11,11,'suecia')
    -> //
+--------------------+-----------------+-------------+----------------+
| codigo_exportacion | codigo_producto | codigo_pais | nombre_pais    |
+--------------------+-----------------+-------------+----------------+
|                  1 |            1200 |           1 | Mexico         |
|                  2 |            1199 |           2 | Estados unidos |
|                  3 |            1198 |           3 | canada         |
|                  4 |            1197 |           4 | alemania       |
|                  5 |            1196 |           5 | portugal       |
|                  6 |            1195 |           6 | brasil         |
|                  7 |            1194 |           7 | argentina      |
|                  8 |            1193 |           8 | chile          |
|                  9 |            1192 |           9 | inglaterra     |
|                 10 |            1191 |          10 | venezuela      |
|                 11 |              11 |          11 | suecia         |
+--------------------+-----------------+-------------+----------------+
11 rows in set (0.00 sec)

Query OK, 0 rows affected (0.02 sec)

EDITAR

mysql> create procedure editar_pais(in codigo_exportacion integer(11), codigo_pais integer(1
    -> begin
    -> update pais set codigo_exportacion=codigo_exportacion, codigo_pais=codigo_pais, nombr
    -> select * from pais;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> call editar_pais(12,12,'colombia')//
+--------------------+-----------------+-------------+-------------+
| codigo_exportacion | codigo_producto | codigo_pais | nombre_pais |
+--------------------+-----------------+-------------+-------------+
|                 12 |               0 |          12 | colombia    |
|                 12 |            1197 |          12 | colombia    |
|                 12 |            1196 |          12 | colombia    |
|                 12 |            1195 |          12 | colombia    |
|                 12 |            1194 |          12 | colombia    |
|                 12 |            1193 |          12 | colombia    |
|                 12 |            1192 |          12 | colombia    |
|                 12 |            1191 |          12 | colombia    |
|                 12 |              11 |          12 | colombia    |
+--------------------+-----------------+-------------+-------------+
9 rows in set (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

mysql>
ELIMINAR
mysql> create procedure eliminar_pais(in codigo_exportacion int(11))
    -> begin
    -> delete from pais where codigo_exportacion=codigo_exportacion;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> call eliminar_pais(12)//
Query OK, 9 rows affected (0.00 sec)

PROCEDIMIENTOS TABLE:  PRODUCTOS
AGREGAR
mysql> create procedure agregar_productos(in codigo_producto int(11), nombre_producto varchar(50), descripcion_producto varchar(60))
    -> begin
    -> insert into productos values (codigo_producto, nombre_producto, descripcion_producto);
    -> select * from productos;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> call agregar_productos(1201, 'gorras', 'producto_de_vestir')//
+-----------------+----------------------------------------+--------------------------+
| codigo_producto | nombre_producto                        | descripcion_producto     |
+-----------------+----------------------------------------+--------------------------+
|            1200 | maquinas y material electrico          | maquinaria empresarial   |
|            1199 | vehiculos terrestres y sus partes      | automoviles              |
|            1198 | perlas,piedras y metales preciosos     | minerales                |
|            1197 | hortalizas,plantas,raises y tuberculos | materiales biologicos    |
|            1196 | bebidas y vinagre                      | bebidas diversas         |
|            1195 | instrumentos y aparatos de optica      | maquinaria oftanmologa   |
|            1194 | papel,carton y sus manofacturas        | materia prima industrial |
|            1193 | aluminio y sus manofacturas            | materia prima industrial |
|            1192 | semillas y frutos oleaginosos          | agricultura              |
|            1191 | hierro y acero                         | material industrializado |
|            1201 | gorras                                 | producto_de_vestir       |
+-----------------+----------------------------------------+--------------------------+
11 rows in set (0.00 sec)

Query OK, 0 rows affected (0.02 sec)
EDITAR
mysql> create procedure editar_produto(in nombre_producto varchar(50), descripcion_produ
    -> begin
    -> update productos set nombre_producto=nombre_producto, descripcion_producto=descri
    -> select * from productos;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> call editar_produto('monitores', 'electrico')//
+-----------------+-----------------+----------------------+
| codigo_producto | nombre_producto | descripcion_producto |
+-----------------+-----------------+----------------------+
|            1200 | monitores       | electrico            |
|            1199 | monitores       | electrico            |
|            1198 | monitores       | electrico            |
|            1197 | monitores       | electrico            |
|            1196 | monitores       | electrico            |
|            1195 | monitores       | electrico            |
|            1194 | monitores       | electrico            |
|            1193 | monitores       | electrico            |
|            1192 | monitores       | electrico            |
|            1191 | monitores       | electrico            |
|            1201 | monitores       | electrico            |
+-----------------+-----------------+----------------------+
11 rows in set (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

ELIMINAR
mysql> create procedure eliminar_productos(in codigo_producto int(11))
    -> begin
    -> delete from productos where codigo_producto=codigo_producto;
    -> select * from productos;
    -> end;
    -> //
Query OK, 0 rows affected (0.00 sec)

mysql> call eliminar_productos(1199)//
Empty set (0.00 sec)


Query OK, 0 rows affected (0.00 sec)

CÓDIGO FUENTE DE LAS INSTRUCCIONES SQL EN ORDEN Y SINTAXIS CORRECTA.

CÓDIGO FUENTE DE LAS INSTRUCCIONES SQL EN ORDEN Y SINTAXIS CORRECTA.

Una transacción es una unidad única de trabajo. Si una transacción tiene éxito, todas las modificaciones de los datos realizadas durante la transacción se confirman y se convierten en una parte permanente de la base de datos. Si una transacción encuentra errores y debe cancelarse o revertirse, se borran todas las modificaciones de los datos
SQL Server funciona en los siguientes tres modos de transacción.
Transacciones de confirmación automática
Cada instrucción individual es una transacción.
Transacciones explícitas
Cada transacción se inicia explícitamente con la instrucción BEGIN TRANSACTION y se termina explícitamente con una instrucción COMMIT o ROLLBACK.
Transacciones implícitas
Se inicia implícitamente una nueva transacción cuando se ha completado la anterior, pero cada transacción se completa explícitamente con una instrucción COMMIT o ROLLBACK.
Transacciones de ámbito de lote
Una transacción implícita o explícita de Transact-SQL que se inicia en una sesión de MARS), que solo es aplicable a MARS, se convierte en una transacción de ámbito de lote. Si no se confirma o revierte una transacción de ámbito de lote cuando se completa el lote, SQL Server la revierte automáticamente.
.


SINTAXIS


PRACTICA: PROCEDIMIENTOS CON INSTRUCCIONES SQL

mysql> create database db123;
Query OK, 1 row affected (0.05 sec)

mysql> use db123;
Database changed
mysql> create table tmujer(id int(2) not null auto_increment primary key, nombre
 varchar(60) not null, tipo varchar(20) null);
Query OK, 0 rows affected (0.24 sec)

mysql> describe tmujer;
+--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| id     | int(2)      | NO   | PRI | NULL    | auto_increment |
| nombre | varchar(60) | NO   |     | NULL    |                |
| tipo   | varchar(20) | YES  |     | NULL    |                |
+--------+-------------+------+-----+---------+----------------+
3 rows in set (0.04 sec)

mysql> delimiter //
mysql> create procedure setmujer(in nombre varchar(60),in tipo varchar(20))
    -> begin
    -> insert into tmujer(nombre,tipo) values (nombre,tipo);
    -> select * from tmujer;
    -> end//
Query OK, 0 rows affected (0.10 sec)

mysql> delimiter ;
mysql> use mysql;
Database changed
mysql> select specific_name from proc where type='procedure';
+---------------+
| specific_name |
+---------------+
| setmujer      |
+---------------+
1 row in set (0.02 sec)

mysql> select body from  proc where specific_name='setmujer';
+-------------------------------------------------------------------------------
--------+
| body
        |
+-------------------------------------------------------------------------------
--------+
| begin
insert into tmujer(nombre,tipo) values (nombre,tipo);
select * from tmujer;
end |
+-------------------------------------------------------------------------------
--------+
1 row in set (0.00 sec)

mysql> use db123;
Database changed
mysql> call setmujer('Maria','Secretaria');
+----+--------+------------+
| id | nombre | tipo       |
+----+--------+------------+
|  1 | Maria  | Secretaria |
+----+--------+------------+
1 row in set (0.05 sec)

Query OK, 0 rows affected (0.07 sec)

mysql> drop procedure setmujer;
Query OK, 0 rows affected (0.10 sec)

mysql> use mysql;
Database changed
mysql> select specific_name from proc;
Empty set (0.00 sec)


mysql>

R.A 3.2

ACTIVIDAD DEL ALUMNO
CBD-02
RUBRICA 3.1 Y 3.2
·         REALIZAR PRESENTACIONES POWER POINT TEMAS RUBRICA 3.1 Y 3.2
·         REALIZAR EL TRABAJO CON TEMAS DE EXPOSICIÓN RUBRICA 3.1
·         INVESTIGAR TEMA PROCEDIMIENTOS Y REALIZAR CUADRO SINÓPTICO DIGITAL
·         REALIZAR LA ACTUALIZACIÓN DEL BLOG

R.A 3.2
CONFIGURACIÓN CONTROLES DE ACCESO Y CIFRADO E INFORMACIÓN UTILIZADA RECURSOS DE MANEJADOR QUE GARANTIZA LA CONFIDENCIALIDAD DE LOS DATOS

A)     CONFIGURACIÓN DE CONTROLES DE ACCESO
·         CREACIÓN, MODIFICACIÓN Y ELIMINACIÓN DE USUARIOS
·         DEFINICIÓN DE ROLES DE PERFILES
·         ASIGNACIÓN DE PRIVILEGIOS A USUARIOS EN EL SISTEMA GESTOR EN AL BDD
·         CREACIÓN, ELIMINACIÓN , LECTURA, MODIFICACIÓN, DE RESPALDOS
B)      RESPALDO DE DATOS
·         TIPOS DE RESPALDOS
·         INCREMENTALES
·         DECREMENTALES
·         RESPALDOS Y MANUALES AUTOMÁTICOS

martes, 10 de junio de 2014

PRACTICA: PROCEDIMIENTOS CON INSTRUCCIONES SQL


qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmrtyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmrtyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmrtyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmrtyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmrtyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmrtyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmrtyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm

CONALEP GUSTAVO BAZ

ALUMNO: AVALOS VARGAS ROBERTO
GRUPO: M403I
UNIDAD: 3.2

PRACTICA: PROCEDIMIENTOS CON INSTRUCCIONES SQL





PRACTICA: PROCEDIMIENTOS CON INSTRUCCIONES SQL
                                                                                                            
mysql> create database db123;
Query OK, 1 row affected (0.05 sec)

mysql> use db123;
Database changed
mysql> create table tmujer(id int(2) not null auto_increment primary key, nombre
 varchar(60) not null, tipo varchar(20) null);
Query OK, 0 rows affected (0.24 sec)

mysql> describe tmujer;
+--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| id     | int(2)      | NO   | PRI | NULL    | auto_increment |
| nombre | varchar(60) | NO   |     | NULL    |                |
| tipo   | varchar(20) | YES  |     | NULL    |                |
+--------+-------------+------+-----+---------+----------------+
3 rows in set (0.04 sec)

mysql> delimiter //
mysql> create procedure setmujer(in nombre varchar(60),in tipo varchar(20))
    -> begin
    -> insert into tmujer(nombre,tipo) values (nombre,tipo);
    -> select * from tmujer;
    -> end//
Query OK, 0 rows affected (0.10 sec)

mysql> delimiter ;
mysql> use mysql;
Database changed
mysql> select specific_name from proc where type='procedure';
+---------------+
| specific_name |
+---------------+
| setmujer      |
+---------------+
1 row in set (0.02 sec)

mysql> select body from  proc where specific_name='setmujer';
+-------------------------------------------------------------------------------
--------+
| body
        |
+-------------------------------------------------------------------------------
--------+
| begin
insert into tmujer(nombre,tipo) values (nombre,tipo);
select * from tmujer;
end |
+-------------------------------------------------------------------------------
--------+
1 row in set (0.00 sec)

mysql> use db123;
Database changed
mysql> call setmujer('Maria','Secretaria');
+----+--------+------------+
| id | nombre | tipo       |
+----+--------+------------+
|  1 | Maria  | Secretaria |
+----+--------+------------+
1 row in set (0.05 sec)

Query OK, 0 rows affected (0.07 sec)

mysql> drop procedure setmujer;
Query OK, 0 rows affected (0.10 sec)

mysql> use mysql;
Database changed
mysql> select specific_name from proc;
Empty set (0.00 sec)


mysql>