martes, 16 de abril de 2013

Bitacora Veterinaria


Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

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> ;
ERROR:
No query specified

mysql> ;
ERROR:
No query specified

mysql> use veterinaria;
Database changed
mysql> show tables;
+---------------------+
| Tables_in_veterinaria |
+---------------------+
| clientes            |
| mascota             |
| veterinaria         |
+---------------------+
3 rows in set (4.19 sec)

mysql> drop table clientes;
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
mysql> exit
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

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 edgarI;
Query OK, 1 row affected (0.81 sec)

mysql> create table clientes(num int not null primary key,nombre varchar(25),direccion varchar(25),telefono varchar(15),oficio varchar(25));
ERROR 1046 (3D000): No database selected
mysql> use edgarI;
Database changed
mysql> create table clientes(num int not null primary key,nombre varchar(25),direccion varchar(25),telefono varchar(15),oficio varchar(25));
Query OK, 0 rows affected (4.99 sec)

mysql> insert into clientes values(1,'Edgar Harry','Los Matorrales #4532','6457843','carpintero');
Query OK, 1 row affected (2.12 sec)

mysql> create table mascota(num int not null primary key,nombre varchar(15),peso float(4),sexo varchar(1),raza varchar(15),FNacimiento varchar(10));
Query OK, 0 rows affected (0.68 sec)

mysql> insert into mascota values(001,'Cane',4.5,'M','pitbull','20-02-2010');
Query OK, 1 row affected (0.63 sec)

mysql> select*from clientes;
+-----+-------------+----------------------+----------+------------+
| num | nombre      | direccion            | telefono | oficio     |
+-----+-------------+----------------------+----------+------------+
|   1 | Edgar Harry | Los Matorrales #4532 | 6457843  | carpintero |
+-----+-------------+----------------------+----------+------------+
1 row in set (0.44 sec)

mysql> select*from mascota;
+-----+--------+------+------+---------+-------------+
| num | nombre | peso | sexo | raza    | FNacimiento |
+-----+--------+------+------+---------+-------------+
|   1 | Cane   |  4.5 | M    | pitbull | 20-02-2010  |
+-----+--------+------+------+---------+-------------+
1 row in set (0.04 sec)


+-----+-------------+
| num | nombre      |
+-----+-------------+
|   1 | Edgar Harry |
+-----+-------------+
1 row in set (0.13 sec)

mysql> select nombre from clientes mascota;
+-------------+
| nombre      |
+-------------+
| Edgar Harry |
+-------------+
1 row in set (0.01 sec)

mysql> drop table mascota;
Query OK, 0 rows affected (5.49 sec)

mysql> drop table clientes;
Query OK, 0 rows affected (0.74 sec)

mysql> create table mascota(NumP int not null primary key,nombre varchar(15),peso float(4),sexo varchar(1),raza varchar(15),FNacimiento varchar(10));
Query OK, 0 rows affected (1.45 sec)

mysql> create table clientes(NumCliente int not null primary key,nombre varchar(25),direccion varchar(25),telefono varchar(15),oficio varchar(25));
Query OK, 0 rows affected (0.25 sec)

mysql> alter table mascota add clientes varchar(25)references clientes(NumCliente);
Query OK, 0 rows affected (3.92 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> select*from clientes;
Empty set (0.90 sec)

mysql> insert into clientes values(1,'Edgar Harry','Los Matorrales #4532','6457843','carpintero');
Query OK, 1 row affected (0.25 sec)

mysql> insert into clientes values(2,'Alejandro Saenz','Oasis #4543','6454343','carnicero');
Query OK, 1 row affected (0.21 sec)

mysql> insert into mascota values(1,'Cane',4.5,'M','pitbull','20-02-2010');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> show create table mascota;



mysql> select*from mascota;
+------+--------+------+------+---------+-------------+----------+
| NumP | nombre | peso | sexo | raza    | FNacimiento | clientes |
+------+--------+------+------+---------+-------------+----------+
|    1 | Cane   |  4.5 | M    | pitbull | 20-02-2010  | 1        |
+------+--------+------+------+---------+-------------+----------+
1 row in set (0.07 sec)

mysql> insert into mascota values(2,'Aleman',15.5,'M','pastorAleman','12-03-2009',2);
Query OK, 1 row affected (0.12 sec)

mysql> select mascota.nombre clientes.nombre from mascota clientes;
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 '.nombre from mascota clientes' at line 1
mysql> select*from clientes;
+------------+-----------------+----------------------+----------+------------+
| NumCliente | nombre          | direccion            | telefono | oficio     |
+------------+-----------------+----------------------+----------+------------+
|          1 | Edgar Harry     | Los Matorrales #4532 | 6457843  | carpintero |
|          2 | Alejandro Saenz | Oasis #4543          | 6454343  | carnicero  |
+------------+-----------------+----------------------+----------+------------+
2 rows in set (0.00 sec)


+--------+--------------------+
| nombre | Nombre Propietario |
+--------+--------------------+
| Cane   | Edgar Harry        |
| Aleman | Alejandro Saenz    |
+--------+--------------------+
2 rows in set (0.12 sec)


+--------+-----------------+
| nombre | nombre          |
+--------+-----------------+
| Cane   | Edgar Harry     |
| Aleman | Alejandro Saenz |
+--------+-----------------+
2 rows in set (0.01 sec)

mysql> select*from clientes;
+------------+-----------------+----------------------+----------+------------+
| NumCliente | nombre          | direccion            | telefono | oficio     |
+------------+-----------------+----------------------+----------+------------+
|          1 | Edgar Harry     | Los Matorrales #4532 | 6457843  | carpintero |
|          2 | Alejandro Saenz | Oasis #4543          | 6454343  | carnicero  |
+------------+-----------------+----------------------+----------+------------+
2 rows in set (0.00 sec)

mysql> select mascota.nombre,clientes.nombre from mascota,clientes ;
+--------+-----------------+
| nombre | nombre          |
+--------+-----------------+
| Cane   | Edgar Harry     |
| Aleman | Edgar Harry     |
| Cane   | Alejandro Saenz |
| Aleman | Alejandro Saenz |
+--------+-----------------+
4 rows in set (0.00 sec)

mysql> select distinct mascota.nombre,clientes.nombre from mascota,clientes ;
+--------+-----------------+
| nombre | nombre          |
+--------+-----------------+
| Cane   | Edgar Harry     |
| Aleman | Edgar Harry     |
| Cane   | Alejandro Saenz |
| Aleman | Alejandro Saenz |
+--------+-----------------+
4 rows in set (0.13 sec)
+--------+-----------------+
| nombre | nombre          |
+--------+-----------------+
| Cane   | Edgar Harry     |
| Aleman | Alejandro Saenz |
+--------+-----------------+
2 rows in set (0.00 sec)

mysql> insert into mascota values(003,'lord',10,'M','labrador','15-04-2011',3);
Query OK, 1 row affected (0.75 sec)


mysql> select*from clientes;
+------------+-----------------+----------------------+----------+--------------+
| NumCliente | nombre          | direccion            | telefono | oficio       |
+------------+-----------------+----------------------+----------+--------------+
|          1 | Edgar Harry     | Los Matorrales #4532 | 6457843  | carpintero   |
|          2 | Alejandro Saenz | Oasis #4543          | 6454343  | carnicero    |
|          3 | Omar Ruiz       | Centro #7834         | 6324354  | Ing.Sistemas |
|          4 | Ivan Morales    | Revolucion #0942     | 6891254  | ContadorP    |
|          5 | Oscar Hernandez | Mezquital #4412      | 6677667  | Electrico    |
|          6 | Jose Salas      | Americas #1972       | 1876578  | Medico       |
+------------+-----------------+----------------------+----------+--------------+
6 rows in set (0.00 sec)

mysql> select*from mascotas;
ERROR 1146 (42S02): Table 'edgari.mascotas' doesn't exist
mysql> select*from mascota;
+------+--------+------+------+----------------+-------------+----------+
| NumP | nombre | peso | sexo | raza           | FNacimiento | clientes |
+------+--------+------+------+----------------+-------------+----------+
|    1 | Cane   |  4.5 | M    | pitbull        | 20-02-2010  | 1        |
|    2 | Aleman | 15.5 | M    | pastorAleman   | 12-03-2009  | 2        |
|    3 | lord   |   10 | M    | labrador       | 15-04-2011  | 3        |
|    4 | pinky  |    3 | M    | Chihuahua      | 11-02-2012  | 4        |
|    5 | pelusa |  1.5 | M    | french poodle  | 02-01-2013  | 5        |
|    6 | BigDog |   50 | M    | Schnauzer      | 05-08-2008  | 6        |
+------+--------+------+------+----------------+-------------+----------+
6 rows in set (0.00 sec)

mysql> select mascota.nombre,clientes.nombre from mascota,clientes where clientes.NumCliente=mascota.clientes;
+--------+-----------------+
| nombre | nombre          |
+--------+-----------------+
| Cane   | Edgar Harry     |
| Aleman | Alejandro Saenz |
| lord   | Omar Ruiz       |
| pinky  | Ivan Morales    |
| pelusa | Oscar Hernandez |
| BigDog | Jose Salas      |
+--------+-----------------+
6 rows in set (0.00 sec)

mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> select mascota.nombre,clientes.nombre from mascota,clientes where clientes.NumCliente=mascota.clientes;
+--------+-----------------+
| nombre | nombre          |
+--------+-----------------+
| Cane   | Edgar Harry     |
| Aleman | Alejandro Saenz |
| lord   | Omar Ruiz       |
| pinky  | Ivan Morales    |
| pelusa | Oscar Hernandez |
| BigDog | Jose Salas      |
+--------+-----------------+
6 rows in set (0.01 sec)

mysql> select *from mascota;
+------+--------+------+------+----------------+-------------+----------+
| NumP | nombre | peso | sexo | raza           | FNacimiento | clientes |
+------+--------+------+------+----------------+-------------+----------+
|    1 | Cane   |  4.5 | M    | pitbull        | 20-02-2010  | 1        |
|    2 | Aleman | 15.5 | M    | pastorAleman   | 12-03-2009  | 2        |
|    3 | lord   |   10 | M    | labrador       | 15-04-2011  | 3        |
|    4 | pinky  |    3 | M    | Chihuahua      | 11-02-2012  | 4        |
|    5 | pelusa |  1.5 | M    | french poodle  | 02-01-2013  | 5        |
|    6 | BigDog |   50 | M    | Schnauzer      | 05-08-2008  | 6        |
+------+--------+------+------+----------------+-------------+----------+
6 rows in set (0.00 sec)

mysql> exit;

No hay comentarios:

Publicar un comentario