UNIVERSIDAD TECNOLÓGICA DE TECAMACHALCO. TECNOLOGÍAS DE LA INFORMACIÓN Y COMUNICACIÓN.
BASE DE DATOS TRABAJO: MODIFICACIONES CON CLAUSULAS PROFESORA: LIC.MARIA DE LOS ANGELES ALUMNAS: CAROLINA SANCHEZ BONILLA EUGENIA LEZAMA RODRIGUEZ
GRUPO: A CUATRIMESTRE: 2 FECHA: 04 DE ABRIL DEL 2011.
INTRODUCCION Para realizar esta practica fue necesario realizar una investigación acerca de las clausulas que son empleadas en el lenguaje de programación MYSQL, retomando las practicas que se realizaron anteriormente con xampp. Algunas de las clausulas que se emplearon fue principalmente –alter tablepara así modificar el nombre de las tablas, agregamos columnas, e ingresamos registros así como para cada uno de las modificaciones se muestra que le agregamos en cada tabla.
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 pinacoteca; Database changed mysql> show databases; +--------------------+ | Database
|
+--------------------+ | information_schema | | cdcol
|
| mysql
|
| phpmyadmin | pinacoteca | test
| |
|
+--------------------+ 6 rows in set (0.00 sec)
mysql> show tables; +----------------------+ | Tables_in_pinacoteca | +----------------------+
Se visualizan las tablas que estรกn dentro de la base de datos pinacoteca.
| cuadros
|
| escuela
|
| mecenas
|
| pinacoteca
|
| pintor
|
| proteger
|
+----------------------+ 6 rows in set (0.02 sec)
mysql> describe pintor;
Describimos a la tabla pintor para ver su contenido
+-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | NOMBRE
| char(20) | NO |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
|
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
+-------------+----------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
mysql> alter table pintor rename artista; Query OK, 0 rows affected (0.05 sec)
mysql> describe artista; +-------------+----------+------+-----+---------+-------+
Vamos a cambiar el nombre de la tabla pintor por artista y ahora describimos la tabla con el nuevo nombre.
| Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | NOMBRE
| char(20) | NO |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
|
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
+-------------+----------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
mysql> describe mecenas; +--------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+--------------+----------+------+-----+---------+-------+ | CURP
| char(10) | NO | PRI | NULL |
| NOMBRE
| char(10) | NO |
| FECHA | PAIS
| char(10) | NO | | char(10) | NO |
| NULL |
|
| NULL | | NULL |
| FNACIIMIENTO | char(10) | NO | | FMUERTE
|
| char(10) | NO |
| |
| NULL | | NULL |
| |
+--------------+----------+------+-----+---------+-------+ 6 rows in set (0.02 sec)
mysql> alter table mecenas rename padrino; Query OK, 0 rows affected (0.03 sec)
En la tabla mecenas cambiaremos el nombre por PADRINO
mysql> describe padrino; +--------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+--------------+----------+------+-----+---------+-------+ | CURP
| char(10) | NO | PRI | NULL |
| NOMBRE
| char(10) | NO |
| FECHA
| char(10) | NO |
| PAIS
| char(10) | NO |
| NULL |
|
| NULL | | NULL |
| FNACIIMIENTO | char(10) | NO | | FMUERTE
|
| char(10) | NO |
| |
| NULL |
|
| NULL |
|
+--------------+----------+------+-----+---------+-------+ 6 rows in set (0.02 sec)
mysql> describe artista;; +-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | NOMBRE
| char(20) | NO |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
+-------------+----------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
|
mysql> describe artista; +-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | NOMBRE
| char(20) | NO |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
|
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
+-------------+----------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
mysql> alter table artista
Cambiamos la columna nombre por RFC; y la describimos para ver el cambio.
-> change nombre RFC char(30); Query OK, 0 rows affected (0.14 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> describe artista; +-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | RFC
| char(30) | YES |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
| CLAVE
| char(10) | YES | MUL | NULL |
| |
| rCURP
| char(20) | NO | MUL | NULL |
|
+-------------+----------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
mysql> alter table artista add col1 char (30); Query OK, 0 rows affected (0.08 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> describe artista; +-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | RFC
| char(30) | YES |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
| col1
| char(30) | YES |
| NULL |
|
|
+-------------+----------+------+-----+---------+-------+ 7 rows in set (0.01 sec)
mysql> alter table artista add edocivil char (30); Query OK, 0 rows affected (0.08 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> describe artista;
Se agrega una columna con la caracterĂstica edocivil con un tipo de dato 30, y se describe para ver el cambio.
+-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | RFC
| char(30) | YES |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
| col1
| char(30) | YES |
| edocivil | char(30) | YES |
| NULL |
|
|
| NULL |
|
+-------------+----------+------+-----+---------+-------+ 8 rows in set (0.00 sec)
mysql> select * from artista; Empty set (0.00 sec)
mysql> alter table artista -> change nombre RFC char(30); Query OK, 0 rows affected (0.14 sec) Records: 0 Duplicates: 0 Warnings: 0
Vamos a cambiar el nombre por RFC, y se describe.
mysql> describe artista; +-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | RFC
| char(30) | YES |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
|
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
+-------------+----------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
mysql> alter table artista add col1 char (30); Query OK, 0 rows affected (0.08 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> describe artista; +-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | RFC
| char(30) | YES |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
|
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
| col1
| char(30) | YES |
| NULL |
|
+-------------+----------+------+-----+---------+-------+ 7 rows in set (0.01 sec)
Vamos a cambiar la tabla agregando una columna que es edocivil; y se describe.
mysql> alter table artista add edocivil char (30); Query OK, 0 rows affected (0.08 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> describe artista; +-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | RFC
| char(30) | YES |
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADAS | char(20) | NO |
| NULL |
|
| CURP
| char(20) | NO | PRI | NULL |
| CLAVE
| char(10) | YES | MUL | NULL |
|
| rCURP
| char(20) | NO | MUL | NULL |
|
| col1
| char(30) | YES |
| edocivil | char(30) | YES |
| NULL |
|
|
| NULL |
+-------------+----------+------+-----+---------+-------+ 8 rows in set (0.00 sec)
|
mysql> insert into artista (fcreacion,tutilizadas,curp) values("1992","DOGS","24 21"); Agregamos registros ala tabla, y se describe pero ahora con un nuevo comando.
Query OK, 1 row affected, 1 warning (0.02 sec)
mysql> select * from artista; +------+-----------+-------------+------+-------+-------+------+----------+ | RFC | FCREACION | TUTILIZADAS | CURP | CLAVE | rCURP | col1 | edocivil | +------+-----------+-------------+------+-------+-------+------+----------+ | 02 |
|
|
| NULL | 1992
| DOGS
| NULL |
| NULL | soltero |
| 2421 | NULL |
| NULL | NULL
+------+-----------+-------------+------+-------+-------+------+----------+ 2 rows in set (0.00 sec)
mysql> describe cuadros; +-------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+ | CODDENOMBRE | char(20) | NO | PRI | NULL | | NOMBRE
| char(20) | NO |
| DIMENSIONES | char(20) | NO |
| NULL |
|
| NULL |
|
| FCREACION | char(20) | NO |
| NULL |
|
| TUTILIZADA | char(20) | NO |
| NULL |
|
| NOMBRE1 | CURP
| char(20) | YES | MUL | NULL |
| char(20) | NO | MUL | NULL |
+-------------+----------+------+-----+---------+-------+
|
| |
|
7 rows in set (0.00 sec)
mysql> insert into cuadros (coddenombre,nombre,tutilizada,fcreacion)values ("mon a","monaliza","oleo","1992");
Agregamos registros ala tabla cuadros; y se visualizan los registros insertados.
Query OK, 1 row affected, 2 warnings (0.03 sec)
mysql> select * from cuadros; +-------------+----------+-------------+-----------+------------+---------+-----+ | CODDENOMBRE | NOMBRE | DIMENSIONES | FCREACION | TUTILIZADA | NOMBRE1 | CURP | +-------------+----------+-------------+-----------+------------+---------+-----+ | mona
| monaliza |
| 1992
| oleo
| NULL |
| +-------------+----------+-------------+-----------+------------+---------+-----+ 1 row in set (0.00 sec)
mysql> describe escuela; +--------+----------+------+-----+---------+-------+ | Field | Type
| Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+ | CLAVE | char(10) | NO | PRI | NULL |
|
| NOMBRE | char(10) | NO |
|
| NULL |
| FECHA | char(10) | NO |
| NULL |
|
+--------+----------+------+-----+---------+-------+ 3 rows in set (0.00 sec)
mysql> insert into escuela(clave,nombre,fecha) values ("3421","manuel","1995"); Query OK, 1 row affected (0.02 sec)
Agregamos registros ala tabla escuela.
mysql> select * from escuela; +-------+--------+-------+ | CLAVE | NOMBRE | FECHA | +-------+--------+-------+ | 3421 | manuel | 1995 | +-------+--------+-------+ 1 row in set (0.00 sec) mysql> describe padrino; +--------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+--------------+----------+------+-----+---------+-------+ | CURP
| char(10) | NO | PRI | NULL |
| NOMBRE
| char(10) | NO |
| FECHA | PAIS
| char(10) | NO | | char(10) | NO |
| NULL |
|
| NULL | | NULL |
| FNACIIMIENTO | char(10) | NO | | FMUERTE
|
| char(10) | NO |
| |
| NULL | | NULL |
| |
+--------------+----------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
mysql> insert into padrino(curp,nombre,fecha,pais) values("gf214","daniel","1503 ","indonesia");
Agregamos registros a la tabla padrino.
Query OK, 1 row affected, 2 warnings (0.02 sec)
mysql> select * from padrino; +-------+--------+-------+-----------+--------------+---------+ | CURP | NOMBRE | FECHA | PAIS
| FNACIIMIENTO | FMUERTE |
+-------+--------+-------+-----------+--------------+---------+ | gf214 | daniel | 1503 | indonesia |
|
|
+-------+--------+-------+-----------+--------------+---------+ 1 row in set (0.00 sec)
mysql> describe pinacoteca; +--------------+----------+------+-----+---------+-------+ | Field
| Type
| Null | Key | Default | Extra |
+--------------+----------+------+-----+---------+-------+ | NOMBRE
| char(20) | NO | PRI | NULL |
|
| CIUDAD
| char(20) | NO |
| NULL |
|
| DIRECION
| char(20) | NO |
| NULL |
|
| MTSCUADRADOS | char(20) | NO |
| NULL |
|
+--------------+----------+------+-----+---------+-------+ 4 rows in set (0.00 sec)
Agregamos registros ala tabla pinacoteca y se visualizan los registros empleados para esta tabla.
mysql> insert into pinacoteca(nombre,ciudad,direcion,mtscuadrados) values("diaeg o rivera", "mexico","14 sur","486") -> ; Query OK, 1 row affected (0.03 sec)
mysql> select * from pinacoteca; +---------------+--------+----------+--------------+ | NOMBRE
| CIUDAD | DIRECION | MTSCUADRADOS |
+---------------+--------+----------+--------------+ | diaego rivera | mexico | 14 sur | 486
|
+---------------+--------+----------+--------------+ 1 row in set (0.00 sec)
mysql> describe proteger; Hasta este punto finalizamos los cambios en la practica de pinacoteca, y para finalizar solo ingresamos exit para salir de la aplicaci贸n.
+-------+----------+------+-----+---------+-------+ | Field | Type
| Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+ | CURP | char(20) | NO | PRI | NULL |
|
| CURP1 | char(10) | NO | PRI | NULL |
|
| CURP2 | char(10) | NO | PRI | NULL |
|
| CURPM | char(10) | NO | PRI | NULL | +-------+----------+------+-----+---------+-------+ 4 rows in set (0.02 sec) mysql> exit
|
CONCLUSION Concluimos que al hacer esta práctica fue mas fácil después de saber como se utiliza cada uno de los comandos.