0% found this document useful (0 votes)
15 views6 pages

Er Password

The document describes the creation of a MySQL database called "biblioteca" and the tables "cliente" and "prestamo" within it. Data is inserted into the tables. Queries are run to view the table structures and select data from the tables. Relationships are established between the tables through foreign keys.

Uploaded by

david ocampo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

Er Password

The document describes the creation of a MySQL database called "biblioteca" and the tables "cliente" and "prestamo" within it. Data is inserted into the tables. Queries are run to view the table structures and select data from the tables. Relationships are established between the tables through foreign keys.

Uploaded by

david ocampo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

er password: ****

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 11

Server version: 8.1.0 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database biblioteca;

Query OK, 1 row affected (0.26 sec)

mysql> use biblioteca;

Database changed

mysql> create table cliente( cedula varchar(10) not null, nombre varchar(200) not null, email
varchar(100) not null unique, telefono varchar(12), primary key (cedula) );

Query OK, 0 rows affected (1.46 sec)

mysql> describe cliente;

+----------+--------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------+--------------+------+-----+---------+-------+

| cedula | varchar(10) | NO | PRI | NULL | |

| nombre | varchar(200) | NO | | NULL | |

| email | varchar(100) | NO | UNI | NULL | |


| telefono | varchar(12) | YES | | NULL | |

+----------+--------------+------+-----+---------+-------+

4 rows in set (0.25 sec)

mysql> create table prestamo( codigo_prestamo int not null auto_increment, fecha_prestamo
date not null, fecha_devolucion date not null, cedula_cliente varchar(10) not null, primary key
(codigo_prestamo), foreign key (cedula_cliente) references cliente (cedula) );

Query OK, 0 rows affected (0.30 sec)

mysql> describe prestamo;

+------------------+-------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+------------------+-------------+------+-----+---------+----------------+

| codigo_prestamo | int | NO | PRI | NULL | auto_increment |

| fecha_prestamo | date | NO | | NULL | |

| fecha_devolucion | date | NO | | NULL | |

| cedula_cliente | varchar(10) | NO | MUL | NULL | |

+------------------+-------------+------+-----+---------+----------------+

4 rows in set (0.00 sec)

mysql> insert into cliente values ("123", "Pepito", "pepe@mail.com", "112345");

Query OK, 1 row affected (0.35 sec)

mysql> insert into cliente(cedula, nombre, email) values ("124", "Juanita", "juana@mail.com");

Query OK, 1 row affected (0.07 sec)

mysql> insert into cliente values ("125", "Pablo", "pablo@mail.com", "7901234");

Query OK, 1 row affected (0.18 sec)

mysql> describe cliente;


+----------+--------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------+--------------+------+-----+---------+-------+

| cedula | varchar(10) | NO | PRI | NULL | |

| nombre | varchar(200) | NO | | NULL | |

| email | varchar(100) | NO | UNI | NULL | |

| telefono | varchar(12) | YES | | NULL | |

+----------+--------------+------+-----+---------+-------+

4 rows in set (0.00 sec)

mysql> select * from cliente;

+--------+---------+----------------+----------+

| cedula | nombre | email | telefono |

+--------+---------+----------------+----------+

| 123 | Pepito | pepe@mail.com | 112345 |

| 124 | Juanita | juana@mail.com | NULL |

| 125 | Pablo | pablo@mail.com | 7901234 |

+--------+---------+----------------+----------+

3 rows in set (0.00 sec)

mysql> insert into cliente values ("007", "Fredy", "zuleta@gmail.com", "3179344");

Query OK, 1 row affected (0.14 sec)

mysql> select * from cliente join prestamo

->

-> select * from cliente join prestamo where c.cedula= "007";

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'select * from cliente join prestamo
where c.cedula= "007"' at line 3
mysql> insert into prestamo(fecha_prestamo, fecha_devolucion, cedula_cliente) values
("2021/02/10", "2021/02/25", "123");

Query OK, 1 row affected, 2 warnings (23.22 sec)

mysql>

mysql>

mysql>

mysql>

mysql> select * from cliente join prestamo where c.cedula= "007";

ERROR 1054 (42S22): Unknown column 'c.cedula' in 'where clause'

mysql> insert into prestamo(fecha_prestamo, fecha_devolucion, cedula_cliente) values


("2021/02/21", "2021/03/08", "125");

Query OK, 1 row affected, 2 warnings (0.21 sec)

mysql> insert into prestamo(fecha_prestamo, fecha_devolucion, cedula_cliente) values


("2021/02/28", "2021/03/14", "123");

Query OK, 1 row affected, 2 warnings (0.26 sec)

mysql> select * from prestamo;

+-----------------+----------------+------------------+----------------+

| codigo_prestamo | fecha_prestamo | fecha_devolucion | cedula_cliente |

+-----------------+----------------+------------------+----------------+

| 1 | 2021-02-10 | 2021-02-25 | 123 |

| 2 | 2021-02-21 | 2021-03-08 | 125 |

| 3 | 2021-02-28 | 2021-03-14 | 123 |

+-----------------+----------------+------------------+----------------+

3 rows in set (0.00 sec)

mysql> select * from cliente inner join prestamo;

+--------+---------+------------------+----------+-----------------+----------------+------------------+----------------+
| cedula | nombre | email | telefono | codigo_prestamo | fecha_prestamo |
fecha_devolucion | cedula_cliente |

+--------+---------+------------------+----------+-----------------+----------------+------------------+----------------+

| 007 | Fredy | zuleta@gmail.com | 3179344 | 3 | 2021-02-28 | 2021-03-14 | 123


|

| 007 | Fredy | zuleta@gmail.com | 3179344 | 2 | 2021-02-21 | 2021-03-08 | 125


|

| 007 | Fredy | zuleta@gmail.com | 3179344 | 1 | 2021-02-10 | 2021-02-25 | 123


|

| 123 | Pepito | pepe@mail.com | 112345 | 3 | 2021-02-28 | 2021-03-14 | 123


|

| 123 | Pepito | pepe@mail.com | 112345 | 2 | 2021-02-21 | 2021-03-08 | 125


|

| 123 | Pepito | pepe@mail.com | 112345 | 1 | 2021-02-10 | 2021-02-25 | 123


|

| 124 | Juanita | juana@mail.com | NULL | 3 | 2021-02-28 | 2021-03-14 | 123


|

| 124 | Juanita | juana@mail.com | NULL | 2 | 2021-02-21 | 2021-03-08 | 125


|

| 124 | Juanita | juana@mail.com | NULL | 1 | 2021-02-10 | 2021-02-25 | 123


|

| 125 | Pablo | pablo@mail.com | 7901234 | 3 | 2021-02-28 | 2021-03-14 | 123


|

| 125 | Pablo | pablo@mail.com | 7901234 | 2 | 2021-02-21 | 2021-03-08 | 125


|

| 125 | Pablo | pablo@mail.com | 7901234 | 1 | 2021-02-10 | 2021-02-25 | 123


|

+--------+---------+------------------+----------+-----------------+----------------+------------------+----------------+

12 rows in set (0.08 sec)

mysql> select * from cliente

-> select * from cliente;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'select * from cliente' at line 2
mysql> select * from cliente;

+--------+---------+------------------+----------+

| cedula | nombre | email | telefono |

+--------+---------+------------------+----------+

| 007 | Fredy | zuleta@gmail.com | 3179344 |

| 123 | Pepito | pepe@mail.com | 112345 |

| 124 | Juanita | juana@mail.com | NULL |

| 125 | Pablo | pablo@mail.com | 7901234 |

+--------+---------+------------------+----------+

4 rows in set (0.00 sec)

mysql> create database biblioteca;

ERROR 1007 (HY000): Can't create database 'biblioteca'; database exists

mysql>

mysql> ^E^E

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy