C:\xampp>cd mysql
C:\xampp\mysql>cd
bin
C:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor.
Commands end with ; or \g.
Your MySQL connection id is 1
Server version:
5.1.41 Source distribution
Type 'help;' or '\h' for help. Type '\c' to
clear the current input statement.
mysql> create database
veterinaria;
Query OK, 1 row affected (0.00 sec)
mysql> use
veterinaria
Database changed
mysql> create table cliente (numcliente int not null primary key,nombre
varchar(
30), telefono int(10),direccion varchar(30), email
varchar(30));
Query OK, 0 rows affected (0.03 sec)
mysql> insert
into cliente values(0001,'sergio castrillo',6562582525,'Camino
nose','sergio@gmail.com');
Query OK, 1 row affected, 1 warning (0.00
sec)
mysql> insert into cliente
values(0002,'harry potter',6562582424,'Camino
real','ha
rrypotter@gmail.com');
Query OK, 1 row affected, 1 warning (0.00
sec)
mysql> insert into cliente values(0003,'pack mendez',6562582754,'Caminar','pack@gmail.com');
Query OK, 1 row
affected, 1 warning (0.00 sec)
mysql> select *from
cliente;
+------------+------------+------------+-------------+-----------------------+
|
numcliente | nombre | telefono | direccion | email
|
+------------+------------+------------+-------------+-----------------------+
|
1 | sergio castrillo | 2147483647 | Camino nose | sergio@gmail.com
|
| 2 | harry potter | 2147483647 | Camino real |
harrypotter@gmail.com |
| 3 | pack mendez | 2147483647 | Caminar
| pack@gmail.com
|
+------------+------------+------------+-------------+-----------------------+
3
rows in set (0.00 sec)
mysql> create table mascota (numcliente int
not null primary key,color varchar(
30),sexo varchar(10),raza
varchar(30),motivoconsulta varchar(30),nombrem varchar
(30));
Query OK, 0
rows affected (0.02 sec)
mysql> insert into mascota
values(0001,'cafe','macho','doberman','dolor estomacal
','tayron');
Query
OK, 1 row affected (0.00 sec)
mysql> insert into mascota
values(0002,'negro','macho','pitbull','fractura','solovino');
Query OK, 1
row affected (0.00 sec)
mysql> insert into mascota
values(0003,'gris','embra','pastor aleman','cortada','
kevin');
Query OK, 1
row affected (0.00 sec)
mysql> select *from
mascota;
+------------+-------+-------+--------------+----------------+---------+
|
numcliente | color | sexo | raza | motivoconsulta | nombrem
|
+------------+-------+-------+--------------+----------------+---------+
|
1 | cafe | macho | doverman | dolor estomacal | tayron |
|
2 | negro | macho | pitbull | fractura | solovino |
|
3 | gris | embra | pastor aleman | cortada | kevin
|
+------------+-------+-------+--------------+----------------+---------+
3
rows in set (0.00 sec)
mysql> alter table cliente add foreign key
(numcliente) references mascota(numcl
iente);
Query OK, 3 rows affected
(0.07 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select
mascota.nombrem,cliente.nombre from mascota,cliente where
cliente.
numcliente=mascota.numcliente;
+---------+------------+
|
nombrem | nombre |
+---------+------------+
| tayron | sergio castrillo
|
| solovino | harry potter |
| kevin | pack mendez
|
+---------+------------+
3 rows in set (0.00 sec)
No hay comentarios:
Publicar un comentario