PRACTICA
REPASO VISTAS
Enter password: ***
Welcome to the MySQL
monitor. Commands end with ; or \g.
Your MySQL connection
id is 1
Server version:
5.0.51b-community-nt-log MySQL Community Edition (GPL)
Type 'help;' or '\h'
for help. Type '\c' to clear the buffer.
mysql> create
database notas;
Query OK, 1 row
affected (0.00 sec)
mysql> use notas;
Database changed
mysql> create table
alumnos(matricula int not null primary key,nombre varchar(30
),apellidos varchar(50),semestre varchar(20),modulo
varchar(50),calif_1 int,cali
f_2 int,calif_3 int);
Query OK, 0 rows
affected (0.08 sec)
mysql> insert into alumnos(matricula,nombre,apellidos,semestre,modulo,calif_1,ca
lif_2,calif_3) values (123,'edith','martinez
hernandez','cuarto','cobd',8,9,10),
(456,'manuel','zavala
contreras','cuarto','cobd',9,8,7),(678,'irving','gonzalez
mena','cuarto','cobd',7,6,5);
Query OK, 3 rows
affected (0.02 sec)
Records: 3 Duplicates: 0
Warnings: 0
mysql> create view
vista_alumnos as select matricula,nombre,apellidos,(calif_1+c
alif_2+calif_3)/3 as
promedio from alumnos;
Query OK, 0 rows
affected (0.03 sec)
mysql> show tables;
+-----------------+
| Tables_in_notas |
+-----------------+
| alumnos |
| vista_alumnos |
+-----------------+
2 rows in set (0.03 sec)
mysql> select * from vista_alumnos;
+-----------+--------+--------------------+----------+
| matricula | nombre | apellidos | promedio |
+-----------+--------+--------------------+----------+
| 123 |
edith | martinez hernandez | 9.0000 |
| 456 |
manuel | zavala contreras | 8.0000 |
| 678 |
irving | gonzalez mena | 6.0000 |
+-----------+--------+--------------------+----------+
3 rows in set (0.00
sec)
mysql> insert into
alumnos values(912,'fabian','mora sanchez','cuarto','cobd',10,9,8);
Query OK, 1 row
affected (0.00 sec)
mysql> select * from alumnos;
+-----------+--------+--------------------+----------+--------+---------+---------+---------+
| matricula | nombre | apellidos | semestre | modulo | calif_1 |
calif_
2 | calif_3 |
+-----------+--------+--------------------+----------+--------+---------+---------+---------+
| 123 |
edith | martinez hernandez | cuarto | cobd
| 8 |9 | 10 |
| 456 |
manuel | zavala contreras | cuarto | cobd
| 9 |8 | 7 |
| 678 |
irving | gonzalez mena | cuarto | cobd
| 7 |6 | 5
|
| 912 |
fabian | mora sanchez | cuarto | cobd
| 10 |9 | 8 |
+-----------+--------+--------------------+----------+--------+---------+---------+---------+
4 rows in set (0.00
sec)
mysql> select * from vista_alumnos;
+-----------+--------+--------------------+----------+
| matricula | nombre | apellidos | promedio |
+-----------+--------+--------------------+----------+
| 123 |
edith | martinez hernandez | 9.0000 |
| 456 |
manuel | zavala contreras |
8.0000 |
| 678 |
irving | gonzalez mena | 6.0000 |
| 912 | fabian | mora sanchez |
9.0000 |
+-----------+--------+--------------------+----------+
4 rows in set (0.00
sec)
PRACTICA
# 12
Enter password: ***
Welcome to the MySQL
monitor. Commands end with ; or \g.
Your MySQL connection
id is 3
Server version:
5.0.51b-community-nt-log MySQL Community Edition (GPL)
Type 'help;' or '\h'
for help. Type '\c' to clear the buffer.
mysql> create
database biblioteca;
Query OK, 1 row
affected (0.02 sec)
mysql> use
biblioteca;
Database changed
mysql> create table
librosdeunaeditorial(titulo varchar(20) not null primary key,isbn int,editorial
varchar(20),paginas int,ano_de_edicion int);
Query OK, 0 rows
affected (0.04 sec)
mysql> insert into
librosdeunaeditorial(titulo,isbn,editorial,paginas,ano_de_edicion) values ('la
quinta ola',9788,'molino',528,1997),('generacio z',9706,'destino',280,1980),('girl
heart boy',9727,'alfaguara',320,1999);
Query OK, 3 rows
affected (0.00 sec)
Records: 3 Duplicates: 0
Warnings: 0
mysql> create view
vista_librosdeunaeditorial as select titulo,isbn,paginas as informacion from librosdeunaeditorial;
Query OK, 0 rows
affected (0.02 sec)
mysql> show tables;
+----------------------------+
|
Tables_in_biblioteca |
+----------------------------+
| librosdeunaeditorial |
| vista_librosdeunaeditorial |
+----------------------------+
2 rows in set (0.00 sec)
mysql> select * from vista_librosdeunaeditorial;
+----------------+------+-------------+
| titulo |
isbn | informacion |
+----------------+------+-------------+
| la quinta ola |
9788 | 528 |
| generacio z |
9706 | 280 |
| girl heart boy |
9727 | 320 |
+----------------+------+-------------+
3 rows in set (0.00
sec)
mysql> drop view vista_librosdeunaeditorial;
Query OK, 0 rows
affected (0.00 sec)
mysql> show tables;
+----------------------+
| Tables_in_biblioteca
|
+----------------------+
| librosdeunaeditorial
|
+----------------------+
1 row in set (0.00
sec)
No hay comentarios.:
Publicar un comentario