BASE DE DATOS

27
TECNOLOGIAS DE LA INFORMACION Y COMUNICACIÓN BASE DE DATOS MARIA DE LOS ANGELES VILLAFAÑE RIOS ALUMNOS SHADOW LITE SP3 Machorro Rosas José Luis 07/04/201 1

description

TRABAJO FINAL

Transcript of BASE DE DATOS

Page 1: BASE DE DATOS

TECNOLOGIAS DE LA INFORMACION Y COMUNICACIÓN

BASE DE DATOS

MARIA DE LOS ANGELES VILLAFAÑE RIOS

ALUMNOS

SHADOW LITE SP3 Machorro Rosas José Luis

07/04/201 1

Page 2: BASE DE DATOS

INTRODUCCION: El objetivo de esta practica es llevar a cabo las practicas que la profesora nos enseno par hacer algunos cambios en las tablas que ya están realizadas en el XAMPP. Así como también saber que funcione cada clausula y cuál es su sintaxis para poder cambiar algunos datos en las tablas ya realizadas.

Page 3: BASE DE DATOS

1.- A continuación se describen los datos a insertar en la Base de Datos Toreros, una vez ingresados los datos mostrar todos los registros de cada una de las tablas. Microsoft Windows XP [Versión 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\EDWARD_DELL>cd ? C:\Documents and Settings\EDWARD_DELL>\cd\ "\cd\" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable. C:\Documents and Settings\EDWARD_DELL>cd \ C:\>cd xampp C:\xampp>cd mysql C:\xampp\mysql>cd bin C:\xampp\mysql\bin>mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.41 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use corridas

Page 4: BASE DE DATOS

Database changed mysql> DESCRIBE PLAZADETOROS; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | Nombre | char(20) | NO | PRI | NULL | | | localidad | char(20) | NO | | NULL | | | direccion | char(20) | NO | | NULL | | | aforo | char(20) | NO | | NULL | | +-----------+----------+------+-----+---------+-------+ 4 rows in set (0.34 sec)

Se utilzo el comando describe para ver la estructura de la tabla plaza de toros mysql> insert into plazadetoros (nombre,localidad,direccion,aforo,) values("El relicario","Puebla","Recinto Ferial","5000"); Query OK, 1 row affected (0.06 sec)

Se utilizó el comando insert into para ingresar registros en la tabla de plaza de toros mysql> insert into plazadetoros (nombre,localidad,direccion,aforo) values("Plaza de toros Mexico","Distrito Federal","Mexico, DF","41000"); Query OK, 1 row affected (0.00 sec) mysql> insert into plazadetoros (nombre,localidad,direccion,aforo,) values("Plaza Monumental de Apizaco","Apizaco","Tlaxcala","7000"); Query OK, 1 row affected (0.00 sec)

Page 5: BASE DE DATOS

mysql> select * from plazadetoros; +-----------------------------+------------------+----------------+-------+----- | nombre | localidad | direccion | aforo | +-----------------------------+------------------+----------------+-------+----- | El relicario | Puebla | Recinto Ferial | 5000 | | Plaza de toros Mexico | Distrito Federal | Mexico, DF | 41000 | | Plaza Monumental de Apizaco | Apizaco | Tlaxcala | 7000 | +-----------------------------+------------------+----------------+-------+-----

Se utilzo el comando select * from para revisar los datos ya ingresados. 3 rows in set (0.08 sec) mysql> DESCRIBE GANADERIA; +----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+----------+------+-----+---------+-------+ | CODIGO | char(20) | NO | PRI | NULL | | | NOMBRE | char(20) | NO | | NULL | | | LOCALIDAD | char(20) | NO | | NULL | | | FECHA_CREACION | char(20) | NO | | NULL | | +----------------+----------+------+-----+---------+-------+ 4 rows in set (0.13 sec) mysql> insert into ganaderia (codigo,nombre,localidad,fecha_creacion) values("G1","La laguna","Tlaxcala","1907"); Query OK, 1 row affected (0.00 sec) mysql> insert into ganaderia (codigo,nombre,localidad,fecha_creacion) values("G2","San Mateo","Zacateca","1906");

Page 6: BASE DE DATOS

Query OK, 1 row affected (0.00 sec) mysql> insert into ganaderia (codigo,nombre,localidad,fecha_creacion) values("G3","Reyes Huerta","Tlaxcala","1904"); Query OK, 1 row affected (0.00 sec) mysql> select * from ganaderia; +--------+--------------+----------------------------------------------+-------- ---+-----------------+ | codigo | nombre | localidad | fecha_creacion |+---- | G1 | La laguna | Tlaxcala | 1907 | | G2 | San Mateo | Zacateca | 1906 | | G3 | Reyes Huerta | Tlaxcala | 1904 | +--------+--------------+----------------------------------------------+-------- ---+-----------------+ 3 rows in set (0.28 sec) mysql> describe corrida; +--------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+----------+------+-----+---------+-------+ | ORDEN | char(20) | NO | PRI | NULL | | | FERIA | char(20) | NO | | NULL | | | ANO | char(20) | NO | | NULL | | | nombre | char(20) | YES | MUL | NULL | | +--------+----------+------+-----+---------+-------+ 4 rows in set (0.13 sec)

Page 7: BASE DE DATOS

mysql> insert into corrida (Orden,Feria,Ano,nombre) values("001","Tlaxcala","2010","Plaza Monumental de Apizaco"); Query OK, 1 row affected (0.28 sec) mysql> insert into corrida (Orden,Feria,Ano,nombre) values("002","San Nicolas","2009","Plaza Monumental de Apizaco"); Query OK, 1 row affected (0.28 sec) mysql> insert into corrida (Orden,Feria,Ano,nombre) values("003","Mayo","2010","El relicario"); Query OK, 1 row affected (0.00 sec) mysql> insert into corrida (Orden,Feria,Ano,nombre) values("004","Mayo","2011","El relicario"); Query OK, 1 row affected (0.00 sec) mysql> insert into corrida (Orden,Feria,Ano,nombre) values("005","Vive Mexico","2010","Plaza de toros Mexico"); Query OK, 1 row affected (0.00 sec) mysql> select * from corrida; +---------------+------------------------+--------------------+----------------- ------------+ | Orden | Feria | Ano | nombre--------------------------------------+ | 001 | Tlaxcala | 2010 | Plaza Monumental de Apizaco | | 002 | San Nicolas | 2009 | Plaza Monumental de Apizaco |

Page 8: BASE DE DATOS

| 003 | Mayo | 2010 | El relicario | | 004 | Mayo | 2011 | El relicario | | 005 | Vive Mexico | 2010 | Plaza de toros M exico | +---------------+------------------------+--------------------+----------------- ------------+ 5 rows in set (0.13 sec) mysql> describe apoderado; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | DNIA | char(20) | NO | PRI | | | | NOMBRE | char(20) | NO | | NULL | | | DIRECCION | char(20) | NO | | NULL | | | TELEFONO | char(20) | NO | | NULL | | +-----------+----------+------+-----+---------+-------+ 4 rows in set (0.34 sec) mysql> insert into apoderado (DNIA,NOMBRE,DIRECCION,telefono) values("2001","Jose Antonio","Puebla","2222086978"); Query OK, 1 row affected (0.00 sec) mysql> insert into apoderado (DNIA,NOMBRE,DIRECCION,telefono) values("2002","Miguel Alejandro","Mexico","5555123223"); Query OK, 1 row affected (0.00 sec)

Page 9: BASE DE DATOS

mysql> insert into apoderado (DNIA,NOMBRE,DIRECCION,telefono) values("2003","Jose Ignacio","Tlaxcala","2234674511"); Query OK, 1 row affected (0.00 sec) mysql> select * from apoderado; +------+------------------+----------+-----------+--------------+------+ | DNIA | NOMBRE | DIRECCION | telefono | DNI1 | +------+------------------+----------+-----------+--------------+------+ | 2001 | Jose Antonio | Puebla | 2222086978 | 2001 | | 2002 | Miguel Alejandro | Mexico | 5555123223 | 2002 | | 2003 | Jose Ignacio | Tlaxcala | 2234674511 | 2003 | +------+------------------+----------+-----------+--------------+------+ 3 rows in set (0.13 sec) mysql> DESCRIBE TOREROS; +-------------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+----------+------+-----+---------+-------+ | DNIT | char(20) | NO | PRI | NULL | | | NOMBRE | char(20) | NO | | NULL | | | APODO | char(20) | NO | | NULL | | | FECHA_ALTERNATIVA | char(20) | NO | | NULL | | | DNIT1 | char(20) | YES | MUL | NULL | | | DNIA | char(20) | YES | MUL | NULL | | +-------------------+----------+------+-----+---------+-------+ 6 rows in set (0.33 sec)

Page 10: BASE DE DATOS

mysql> insert into TOREROS (DNIT,NOMBRE,APODO,FECHA_ALTERNATIVA,DNIT1,DNIA) values("1001","Jose Rubio","El Joselito","20-12-1978","Vacio","2003"); Query OK, 1 row affected (0.00 sec) mysql> insert into TOREROS (DNIT,NOMBRE,APODO,FECHA_ALTERNATIVA,DNIT1,DNIA) values("1002","Daniel Sotomayor","El Sotoluco","12-01-1985","1001","2003"); Query OK, 1 row affected (0.00 sec) mysql> insert into TOREROS (DNIT,NOMBRE,APODO,FECHA_ALTERNATIVA,DNIT1,DNIA) values("1003",”Carlos Aurelio","El Yeyo","02-07-1990","1001","2002"); Query OK, 1 row affected (0.00 sec) mysql> insert into TOREROS (DNIT,NOMBRE,APODO,FECHA_ALTERNATIVA,DNIT1,DNIA) values("1004",”Alfredo","El cuñado","01-03-1992","1003","2001"); Query OK, 1 row affected (0.00 sec) mysql> select * from toreros; +------+------------------+-------------+------------------------+-------------- -----+-------+ | DNIT | NOMBRE | APODO | FECHA_ALTERNATIVA | DNIT1 | DNIA | +------+------------------+-------------+------------------------+-------------- | 1001 | Jose Rubio | El Joselito | 20-12-1978 |vacio | 2003 | | 1002 | Daniel Sotomayor | El Sotoluco | 12-01-1985 | 1001 | 2003 | | 1003 | Carlos Aurelio | El Yeyo | 02-07-1990 | 1002 | 2003 | | 1004 | Alfredo | El cuñado | 02-07-1990 | 1003 | 2003 | +------+------------------+-------------+------------------------+-------------- 4 rows in set (0.00 sec) mysql> describe toros; +-----------+----------+------+-----+---------+-------+

Page 11: BASE DE DATOS

| Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | No | char(20) | NO | PRI | NULL | | | NOMBRE | char(20) | NO | | NULL | | | COLOR | char(20) | NO | | NULL | | | Ano_nacio | char(20) | NO | | NULL | | | ORDEN | char(20) | YES | MUL | NULL | | | CODIGO | char(20) | NO | MUL | NULL | | +-----------+----------+------+-----+---------+-------+ 6 rows in set (0.03 sec) mysql> mysql> insert into toros (No,NOMBRE,COLOR,Ano_nacio,CODIGO,ORDEN) values("1","el pajarito","negro","1999"," G3","005"); Query OK, 1 row affected (0.00 sec) mysql> insert into toros (No,NOMBRE,COLOR,Ano_nacio, CODIGO,ORDEN) values("2","Atrevido","pinto","1998"," G1","005"); Query OK, 1 row affected (0.00 sec) mysql> insert into toros (No,NOMBRE,COLOR,Ano_nacio, CODIGO,ORDEN) values("3","Valedor","negro","1999"," G2","001"); Query OK, 1 row affected (0.00 sec) mysql> insert into toros (No,NOMBRE,COLOR,Ano_nacio, CODIGO,ORDEN) values("4","Navegante","Pinto","1998"," G2","004"); Query OK, 1 row affected (0.00 sec)

Page 12: BASE DE DATOS

mysql> insert into toros (No,NOMBRE,COLOR,Ano_nacio, CODIGO,ORDEN) values("5","Islero","negro","1999"," G1","002"); Query OK, 1 row affected (0.00 sec) mysql> insert into toros (No,NOMBRE,COLOR,Ano_nacio, CODIGO,ORDEN) values("6","cabatisto","pinto","1999"," G3","003"); Query OK, 1 row affected (0.00 sec) mysql> insert into toros (No,NOMBRE,COLOR,Ano_nacio, CODIGO,ORDEN) values("7","jabonero","pinto","1998"," G2","004"); Query OK, 1 row affected (0.00 sec) mysql> select * from toros; +---------------+-------------+-------+-------------------+-------------------+- ---------------------+---------------+--------+ | No | NOMBRE | COLOR | Ano_nacio | CODIGO|ORDEN | +---------------+-------------+-------+-------------------+-------------------+- | 1 | el pajarito | negro | 1999 | G3 | 005 | | 2 | atrevido | pinto | 1998 | G1 | 005 | | | 3 | valedor | negro | 1999 | G2 | 001 | | 4 | navegante | pinto | 1998 | G2 | 004 || | 5 | islero | negro | 1999 | G1 | 002 || | 6 | cabatisto | pinto | 1999 | G3 | 003 || | 7 | jabonero | pinto | 1998 | G2 | 004 | | +---------------+-------------+-------+-------------------+-------------------+- ---------------------+---------------+--------+ 7 rows in set (0.02 sec) mysql> describe premio;

Page 13: BASE DE DATOS

+--------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+----------+------+-----+---------+-------+ | No. Premio | int(11) | NO | PRI | 0 | | | orejas | char(10) | NO | | NULL | | | rabos | char(10) | NO | | NULL | | | Puerta_grande | char(4) | YES | | NULL | | | DNIT | char(10) | YES | MUL | NULL | | +--------------+----------+------+-----+---------+-------+ 5 rows in set (0.27 sec) mysql> insert into premio (No.premio,orejas,rabos,Puerta_grande,DNIT) va lues("3178","1","0","no","1001"); Query OK, 1 row affected (0.08 sec) mysql> insert into premio (No.premio,orejas,rabos,Puerta_grande,DNIT) va lues("3145","4","2","si","1002"); Query OK, 1 row affected (0.00 sec) mysql> insert into premio (No.premio,orejas,rabos,Puerta_grande,DNIT) va lues("3122","2","1","si","1003"); Query OK, 1 row affected (0.00 sec) mysql> insert into premio (No.premio,orejas,rabos,Puerta_grande,DNIT) va lues("3131","1","0","no","1004"); Query OK, 1 row affected (0.00 sec) mysql> select * from premio;

Page 14: BASE DE DATOS

+--------+----------------+---------------+-----------+------+ | No.premio| orejas | rabos | Puerta_grande | DNIT | +--------+----------------+---------------+-----------+------+ | 3178 | 1 | 0 | no | 1001 | | 3145 | 4 | 2 | si | 1002 | | 3122 | 2 | 1 | si | 1003 | | 3131 | 1 | 0 | no | 1004 | +--------+----------------+---------------+-----------+------+ 4 rows in set (0.00 sec) mysql> describe actuar; +-------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+-------+ | ORDEN | char(20) | NO | PRI | NULL | | | DNIT | char(20) | NO | PRI | NULL | | +-------+----------+------+-----+---------+-------+ 2 rows in set (0.33 sec) mysql> insert into actuar (Orden,DNIT) values("004","1002"); Query OK, 1 row affected (0.00 sec) mysql> insert into actuar (Orden,DNIT) values("004","10002"); Query OK, 1 row affected (0.00 sec) mysql> insert into actuar (Orden,DNIT) values("001","1003"); Query OK, 1 row affected (0.00 sec)

Page 15: BASE DE DATOS

mysql> insert into actuar (Orden,DNIT) values("005","1001"); Query OK, 1 row affected (0.00 sec) mysql> insert into actuar (Orden,DNIT) values("005","10001"); Query OK, 1 row affected (0.00 sec) mysql> insert into actuar (Orden,DNIT) values("003","1004"); Query OK, 1 row affected (0.00 sec) mysql> insert into actuar (Orden,DNIT) values("003","10004"); Query OK, 1 row affected (0.00 sec) mysql> select * from actuar; +---------------+------+ | ORDEN | DNIT | +---------------+------+ | 004 | 1002 | | 004 | 10002 | | 001 | 1003 | | 005 | 1001 | | 005 | 10001 | | 003 | 1004 | | 002 | 1001 | +---------------+------+ 5 rows in set (0.11 sec)

Page 16: BASE DE DATOS

2.- Cambiar el nombre de la columna Año_nacio de la tabla toros por Fecha_nacimiento mysql> alter table toros >change Ano_nacio Fecha_nacimiento char(30); Query OK, 7 rows affected (0.34 sec) Records: 7 Duplicates: 0 Warnings: 0

Se utilzo el comando alter table change sirve para cambiar el nombre de la columna año_nacio por fecha de nacimiento mysql> describe toros; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ | No | char(20) | NO | PRI | NULL | | | NOMBRE | char(20) | NO | | NULL | | | COLOR | char(20) | NO | | NULL | | | Fecha_nacimiento | char(30) | NO | | NULL | | | ORDEN | char(20) | YES | MUL | NULL | | | CODIGO | char(20) | NO | MUL | NULL | | +-----------+----------+------+-----+---------+-------+ 6 rows in set (0.03 sec)

Page 17: BASE DE DATOS

3.- Cambiar el nombre de la columna DNIT1 que es la llave foránea de la tabla toreros por Padrino. mysql> alter table toreros >change DNIT1 Padrino char(30); Query OK, 7 rows affected (0.34 sec) Records: 7 Duplicates: 0 Warnings: 0 Se utilzo el comando sirve para cambiar el nombre de la columna DNIT1 por Padrino mysql> DESCRIBE TOREROS; +-------------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+----------+------+-----+---------+-------+ | DNIT | char(20) | NO | PRI | NULL | | | NOMBRE | char(20) | NO | | NULL | | | APODO | char(20) | NO | | NULL | | | FECHA_ALTERNATIVA | char(20) | NO | | NULL | | | PADRINO | char(30) | YES | MUL | NULL | | | DNIA | char(20) | YES | MUL | NULL | | +-------------------+----------+------+-----+---------+-------+ 6 rows in set (0.33 sec)

Page 18: BASE DE DATOS

4.- Modificar el registro 1002 de la Tabla Toreros en el campo “Apodo” cambiar el que existe por “El Zotoluco”. mysql> UPDATE TOREROS SET APODO='ZOTOLUCO' WHERE DNIT='El sotoluco'; Query OK, 1 row affected (0.00 sec)

Se utilzo el comando sirve para Update para modificar un registro mysql> select * from toreros; +------+------------------+-------------+------------------------+-------------- -----+-------+ | DNIT | NOMBRE | APODO | FECHA_ALTERNATIVA | DNIT1 | DNIA | +------+------------------+-------------+------------------------+-------------- | 1001 | Jose Rubio | El Joselito | 20-12-1978 |vacio | 2003 | | 1002 | Daniel Sotomayor | ZOTOLUCO | 12-01-1985 | 1001 | 2003 | | 1003 | Carlos Aurelio | El Yeyo | 02-07-1990 | 1002 | 2003 | | 1004 | Carlos Aurelio | El Yeyo | 02-07-1990 | 1003 | 2003 | +------+------------------+-------------+------------------------+-------------- 4 rows in set (0.00 sec)

Page 19: BASE DE DATOS

5.- Mostrar los datos de los Toreros ordenados de la A a la Z. mysql>select * from toreros order by NOMBRE; mysql> select * from toreros; +------+------------------+-------------+------------------------+-------------- -----+-------+ | DNIT | NOMBRE | APODO | FECHA_ALTERNATIVA | DNIT1 | DNIA | +------+------------------+-------------+------------------------+-------------- | 1004 | Alfredo | El cuñado | 02-07-1990 | 1003 | 2003 | | 1003 | Carlos Aurelio | El Yeyo | 02-07-1990 | 1002 | 2003 | | 1002 | Daniel Sotomayor | El Sotoluco | 12-01-1985 | 1001 | 2003 | | 1001 | Jose Rubio | El Joselito | 20-12-1978 |vacio | 2003 | +------+------------------+-------------+------------------------+-------------- 4 rows in set (0.00 sec)

Page 20: BASE DE DATOS

6.- Mostrar las corridas ordenadas por Año. (Ordenadas descendentemente). mysql> select * from corrida order by ANO desc; mysql> select * from corrida; +---------------+------------------------+--------------------+----------------- ------------+ | Orden | Feria | Ano | nombre--------------------------------------+ | 004 | Mayo | 2011 | El relicario | | 001 | Tlaxcala | 2010 | Plaza Monumentalde Apizaco | | 003 | Mayo | 2010 | El relicario | | 005 | Vive Mexico | 2010 | Plaza de toros Mexico | | 002 | San Nicolas | 2009 | Plaza Monumental de Apizaco | +---------------+------------------------+--------------------+----------------- ------------+ 5 rows in set (0.13 sec)

Page 21: BASE DE DATOS

7.- Cambiar el Nombre de la Tabla Actúan por el Nombre Participan. mysql> alter table acturar rename participan; Query OK, 0 rows affected (0.02 sec) mysql> describe participan; +-------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+-------+ | ORDEN | char(20) | NO | PRI | NULL | | | DNIT | char(20) | NO | PRI | NULL | | +-------+----------+------+-----+---------+-------+ 2 rows in set (0.33 sec)

Page 22: BASE DE DATOS

8.- Mostrar todos los datos de las tablas Toreros y Premios considerando la siguiente condición: Toreros.DNIT=Premios.DNTI

Page 23: BASE DE DATOS

9.- Modificar el registro 7 de la tabla Toros en el campo Color cambiar Pinto por Negro mysql> UPDATE toros set color='pinto' where color='negro'; Query OK, 3 rows affected (0.01 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> select * from toros; +---------------+-------------+-------+-------------------+-------------------+- ---------------------+---------------+--------+ | No | NOMBRE | COLOR | Ano_nacio | CODIGO|ORDEN | +---------------+-------------+-------+-------------------+-------------------+- | 1 | el pajarito | negro | 1999 | G3 | 005 | | 2 | atrevido | pinto | 1998 | G1 | 005 | | | 3 | valedor | negro | 1999 | G2 | 001 | | 4 | navegante | pinto | 1998 | G2 | 004 || | 5 | islero | negro | 1999 | G1 | 002 || | 6 | cabatisto | pinto | 1999 | G3 | 003 || | 7 | jabonero | negro | 1998 | G2 | 004 | | +---------------+-------------+-------+-------------------+-------------------+- ---------------------+---------------+--------+ 7 rows in set (0.02 sec)

Page 24: BASE DE DATOS

10.- Añadir una columna con el nombre Peso con tipo de dato Entero en la tabla de Toros e ingresar los datos de peso a cada uno de los registros. mysql>alter table toros >add peso char(30); Query OK, 1 row affected (0.00 sec) mysql> update toros set peso='500' where numero='1'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> update toros set peso='450' where numero='2'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> update toros set peso='487' where numero='3'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> update toros set peso='460' where numero='4'; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> update toros set peso='510' where numero='5'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0

Page 25: BASE DE DATOS

mysql> update toros set peso='490' where numero='6'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> update toros set peso='505' where numero='7'; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0 mysql> select * from toros; +---------------+-------------+-------+-------------------+-------------------+- | No | NOMBRE | COLOR | Ano_nacio | CODIGO|ORDEN |peso +---------------+-------------+-------+-------------------+-------------------+- | 1 | el pajarito | negro | 1999 | G3 | 005 |500 | | 2 | atrevido | pinto | 1998 | G1 | 005 | 450 | | 3 | valedor | negro | 1999 | G2 | 001 |487 | | 4 | navegante | pinto | 1998 | G2 | 004 |460 | | 5 | islero | negro | 1999 | G1 | 002 |510 | | 6 | cabatisto | pinto | 1999 | G3 | 003 |490 | | 7 | jabonero | pinto | 1998 | G2 | 004 | 505 | +---------------+-------------+-------+-------------------+-------------------+- ---------------------+---------------+--------+

Page 26: BASE DE DATOS

11.- Mostrar los registros de la tabla Toros ordenados por el Peso. mysql> select * from toros order by peso desc; Query OK, 0 rows affected (0.00 sec) mysql> select * from toros; +---------------+-------------+-------+-------------------+-------------------+- | No | NOMBRE | COLOR | Ano_nacio | CODIGO|ORDEN |peso +---------------+-------------+-------+-------------------+-------------------+- | 5 | islero | negro | 1999 | G1 | 002 |510 | | 7 | jabonero | pinto | 1998 | G2 | 004 | 505 | | 1 | el pajarito | negro | 1999 | G3 | 005 |500 | | 6 | cabatisto | pinto | 1999 | G3 | 003 |490 | | 3 | valedor | negro | 1999 | G2 | 001 |487 | | 4 | navegante | pinto | 1998 | G2 | 004 |460 | | 2 | atrevido | pinto | 1998 | G1 | 005 | 450 | +---------------+-------------+-------+-------------------+-------------------+- ---------------------+---------------+--------+

Page 27: BASE DE DATOS

Conclusión

Al empezar a hacer esta practica se nos hizo un poco difícil ya que al empezar a poner las clausulas el XAMPP nos marcaba error pero le preguntamos a un compañero de quinto cuatrimestre y nos dijo en que estábamos fallando, corregimos y fue como nos resulto lo que queríamos, además de que ya no nos acordábamos de cómo iba la sintaxis y toda clausula y poníamos cosas que no eran o nos faltaban detalles pero poco a poco le fuimos entendiendo y así poder concluir el trabajo. Lo que hemos aprendido durante este curso sabemos que nos servirá de mucho en lo que venga y agradecemos a la profesora, pues aunque se nos dificultaba y creíamos que era mucho trabajo logro que nuestros conocimientos se nos fortalecieran.