miércoles, 23 de noviembre de 2011

PROCEDIMIENTOS

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
| videoclub          |
+--------------------+
4 rows in set (0.00 sec)

mysql> use videoclub;
Database changed
mysql> \. peliculas.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected, 1 warning (0.00 sec)

Database changed
Query OK, 0 rows affected (0.14 sec)

Query OK, 0 rows affected (0.10 sec)

Query OK, 0 rows affected (0.09 sec)

Query OK, 0 rows affected (0.07 sec)

Query OK, 0 rows affected (0.11 sec)

Query OK, 0 rows affected (0.17 sec)

Query OK, 0 rows affected (0.25 sec)

Query OK, 0 rows affected (0.22 sec)

Query OK, 0 rows affected (0.18 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+---------------------------------+
| Tables_in_videoclub             |
+---------------------------------+
| actor                           |
| director                        |
| doc rent                        |
| ejemplar                        |
| pelicula                        |
| pelicula_has_actor              |
| socio                           |
| socio_has_ejemplar              |
| socio_has_ejemplar_has_doc rent |
+---------------------------------+
9 rows in set (0.01 sec)

mysql> describe pelicula;
+--------------+-------------+------+-----+---------+-------+
| Field        | Type        | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| codigo p     | int(11)     | NO   | PRI | NULL    |       |
| titulo       | varchar(45) | YES  |     | NULL    |       |
| nacionalidad | varchar(45) | YES  |     | NULL    |       |
| productora   | varchar(45) | YES  |     | NULL    |       |
| fecha        | varchar(45) | YES  |     | NULL    |       |
+--------------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

mysql> insert into pelicula values ('12','titanic','inglesa','warner','12-03-90'
);
Query OK, 1 row affected (0.05 sec)

mysql> insert into pelicula values ('13','planetasimios','estadounidense','warne
r','23-05-85');
Query OK, 1 row affected (0.08 sec)

mysql> select codigo p,titulo,nacionalidad,productora,fecha from pelicula;
ERROR 1054 (42S22): Unknown column 'codigo' in 'field list'
mysql> select codigo p , titulo , nacionalidad , productora , fecha from pelicul
a;
ERROR 1054 (42S22): Unknown column 'codigo' in 'field list'
mysql> select titulo , nacionalidad , productora , fecha from pelicula;
+---------------+----------------+------------+----------+
| titulo        | nacionalidad   | productora | fecha    |
+---------------+----------------+------------+----------+
| titanic       | inglesa        | warner     | 12-03-90 |
| planetasimios | estadounidense | warner     | 23-05-85 |
+---------------+----------------+------------+----------+
2 rows in set (0.00 sec)

mysql> drop database videoclub;
Query OK, 9 rows affected (0.57 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> create database videoclub;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
| videoclub          |
+--------------------+
4 rows in set (0.00 sec)

mysql> use videoclub;
Database changed
mysql> \. peliculas.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected, 1 warning (0.00 sec)

Database changed
Query OK, 0 rows affected (0.13 sec)

Query OK, 0 rows affected (0.09 sec)

Query OK, 0 rows affected (0.09 sec)

Query OK, 0 rows affected (0.10 sec)

Query OK, 0 rows affected (0.10 sec)

Query OK, 0 rows affected (0.11 sec)

Query OK, 0 rows affected (0.13 sec)

Query OK, 0 rows affected (0.14 sec)

Query OK, 0 rows affected (0.14 sec)

Query OK, 0 rows affected (0.14 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+---------------------------------+
| Tables_in_videoclub             |
+---------------------------------+
| actor                           |
| director                        |
| doc rent                        |
| doc rent_has_socio_has_ejemplar |
| ejemplar                        |
| pelicula                        |
| pelicula_has_actor              |
| pelicula_has_actor1             |
| socio                           |
| socio_has_ejemplar              |
+---------------------------------+
10 rows in set (0.01 sec)

mysql> describe socio;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| dni       | int(11)     | NO   | PRI | NULL    |       |
| nombre    | varchar(45) | YES  |     | NULL    |       |
| direccion | varchar(45) | YES  |     | NULL    |       |
| telefono  | varchar(45) | YES  |     | NULL    |       |
| socio_dni | int(11)     | NO   | MUL | NULL    |       |
+-----------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

mysql>