martes, 16 de abril de 2013

Creación De Indices en BD 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cdcol              |
| mysql              |
| performance_schema |
| phpmyadmin         |
| test               |
| veterinaria            |
| webauth            |
+--------------------+
8 rows in set (0.05 sec)

mysql> use veterinaria;
Database changed
mysql> show tables;
+-------------------+
| Tables_in_veterinaria |
+-------------------+
| antenfermedades   |
| caracteristicas   |
| clientes          |
| direccion         |
| hmedica           |
| info              |
| mascota           |
| mconsulta         |
| servicios         |
+-------------------+
10 rows in set (0.00 sec)

mysql> describe info;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| num     | int(11)     | NO   | PRI | NULL    |       |
| NombreC | varchar(25) | YES  |     | NULL    |       |
| NombreM | varchar(25) | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
3 rows in set (0.82 sec)


mysql> create index part_of_name on info (num(4));
Query OK, 0 rows affected (0.65 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> create index part_of_num on info (num(4));
Query OK, 0 rows affected (0.57 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> create index part_of_NombreC on info (NombreC(25));
Query OK, 0 rows affected (0.26 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> create index part_of_NombreM on info (NombreM(25));
Query OK, 0 rows affected (0.09 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> describe mascota;
+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| NumP        | int(11)     | NO   | PRI | NULL    |       |
| nombre      | varchar(15) | YES  |     | NULL    |       |
| peso        | float       | YES  |     | NULL    |       |
| sexo        | varchar(1)  | YES  |     | NULL    |       |
| raza        | varchar(15) | YES  |     | NULL    |       |
| FNacimiento | varchar(10) | YES  |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+
6 rows in set (0.13 sec)


mysql> create index infmascota on mascota (sexo(1));
Query OK, 5 rows affected (0.20 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> create index infraza on mascota (raza(15));
Query OK, 5 rows affected (0.60 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> describe servicios;
ERROR 1146 (42S02): Table 'veterin.servicios' doesn't exist
mysql> describe servicio;
ERROR 1146 (42S02): Table 'veterin.servicio' doesn't exist
mysql> describe servicios;
ERROR 1146 (42S02): Table 'veterin.servicios' doesn't exist
mysql> describe clientes;
+------------+-------------+------+-----+---------+-------+
| Field      | Type        | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| NumCliente | int(11)     | NO   | PRI | NULL    |       |
| nombrec    | varchar(25) | YES  |     | NULL    |       |
| direccion  | varchar(25) | YES  |     | NULL    |       |
| telefono   | varchar(15) | YES  |     | NULL    |       |
| oficio     | varchar(25) | YES  |     | NULL    |       |
+------------+-------------+------+-----+---------+-------+
5 rows in set (0.49 sec)

mysql> create index FClientes on clientes(NumClientes(11));
ERROR 1072 (42000): Key column 'NumClientes' doesn't exist in table

mysql> create index FClientes on clientes(NumCliente(4));
Query OK, 5 rows affected (0.59 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> create index FTelefono on clientes(telefono(15));
Query OK, 5 rows affected (0.54 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> exit

No hay comentarios:

Publicar un comentario