ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Ejemplo de mysql consola

Jesus RossanoTrabajo29 de Abril de 2020

9.770 Palabras (40 Páginas)265 Visitas

Página 1 de 40

UNIVERSIDAD MEXIQUENSE DEL BICENTENARIO

Unidad de Estudios Superiores

                                        <<TENANGO DEL VALLE>>

PRACTICAS “Terminal de autobuses”

materia:

<>

Presenta:

<< JESUS NOE ROSSANO ESTRADA >>


Introducción

A continuación se presentara la creación de una base de datos de una terminal de autobuses, la cual se insertaron los datos tanto de las sucursales, empleados, boletos, clientes, autobuses, choferes, rutas y ventas; lo cual se representara las consultas de información, por ejemplo; cuantos empleados están en la terminal de autobuses o que un empleado venda boletos la cual va a estar registrada en la base de datos.


Índice

Contenido

Caratula        1

Introducción        2

Indice        3

Diagrama entidad relación        4

Diagrama relacional        5

Código de la creación de la base de datos        6

Consultas        15

Conclusiones        33


Diagrama entidad relación

[pic 3]


Diagrama relacional

[pic 4]

Código de la creación de la base de datos

C:\Users\noees\OneDrive\Escritorio>title TERMINAL DE AUTOBUSES

C:\Users\noees\OneDrive\Escritorio>color 1B

C:\Users\noees\OneDrive\Escritorio>cd..

C:\Users\noees\OneDrive>cd..

C:\Users\noees>cd..

C:\Users>cd..

C:\>cd wamp/bin/mysql/mysql5.5.8/bin

C:\wamp\bin\mysql\mysql5.5.8\bin>mysql -u root -p

Enter password:

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

Your MySQL connection id is 301

Server version: 5.5.8-log MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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> USE TERMINALDEAUTOBUSES;

Database changed

mysql> DESCRIBE SUCURSALES;

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

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

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

| id_su        | int(4)       | NO   | PRI | NULL    | auto_increment |

| Nombre_su    | varchar(100) | YES  |     | NULL    |                |

| ubicacion_su | varchar(100) | YES  |     | NULL    |                |

| tel_su       | varchar(100) | YES  |     | NULL    |                |

| horarios_su  | varchar(100) | YES  |     | NULL    |                |

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

5 rows in set (0.01 sec)

mysql> SELECT*FROM SUCURSALES;

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

| id_su | Nombre_su       | ubicacion_su                                                               | tel_su      | horarios_su |

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

|     4 | TERMINAL_TOLUCA | #101 Interior 101 Felipe Berriozabal Valle Verde 50140 Toluca de Lerdo Méx |  7222170196 | las 24hrs   |

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

1 row in set (0.00 sec)

mysql> DESCRIBE COSTOS;

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

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

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

| id_c         | int(4)       | NO   | PRI | NULL    | auto_increment |

| basico_c     | varchar(100) | YES  |     | NULL    |                |

| sencillo_c   | varchar(100) | YES  |     | NULL    |                |

| intermedio_c | varchar(100) | YES  |     | NULL    |                |

| doble_c      | varchar(100) | YES  |     | NULL    |                |

| lujo_c       | varchar(100) | YES  |     | NULL    |                |

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

6 rows in set (0.01 sec)

mysql> DESCRIBE COSTOS;

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

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

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

| id_co          | int(11)      | NO   | PRI | NULL    | auto_increment |

| descripcion_co | varchar(100) | YES  |     | NULL    |                |

| costos_co      | varchar(100) | YES  |     | NULL    |                |

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

3 rows in set (0.01 sec)

mysql> INSERT TABLE COSTOS VALUES('','VIAJE SENCILLO','100');

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 'TABLE COSTOS VALUES('','VIAJE SENCILLO','100')' at line 1

mysql> INSERT TABLE COSTOS VALUES("","VIAJE SENCILLO","100");

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 'TABLE COSTOS VALUES("","VIAJE SENCILLO","100")' at line 1

mysql> INSERT INTO TERMINALES VALUES("","TERMINAL TENANGO DEL VALLE","TENANGO DEL VALLE","DOMINGO-SABADO DE 6:00 AM A 10:00 PM");

ERROR 1146 (42S02): Table 'terminaldeautobuses.terminales' doesn't exist

mysql> INSERT INTO COSTOS VALUES("","VIAJE SENCILLO",100);

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

mysql> INSERT INTO COSTOS VALUES("","VIAJE BASICO",80);

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

mysql> INSERT INTO COSTOS VALUES("","VIAJE DOBLE",160);

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

mysql> INSERT INTO COSTOS VALUES("","VIAJE INTERMEDIO",140);

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

mysql> INSERT INTO COSTOS VALUES("","VIAJE DE LUJO",300);

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

mysql> SELECT * FROM COSTOS;

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

| id_co | descripcion_co   | costos_co |

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

|     1 | VIAJE SENCILLO   | 100       |

|     2 | VIAJE BASICO     | 80        |

|     3 | VIAJE DOBLE      | 160       |

|     4 | VIAJE INTERMEDIO | 140       |

|     5 | VIAJE DE LUJO    | 300       |

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

5 rows in set (0.00 sec)

mysql> CREATE TABLE RUTAS(

    -> id_r int,

    -> destino_r varchar(100),

    -> duracion_r varchar(100),

    -> Priamry Key (id_r,COSTOS_id_co),

    -> INDEX RUTAS_FKIndex1(COSTOS_id_co),

    -> FOREIGN KEY(COSTOS_id_co)

    -> REFERENCES COSTOS(id_co)

    -> ON DELETE NO ACTION

    -> ON UPDATE NO ACTION);

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 'Key (id_r,COSTOS_id_co),

...

Descargar como (para miembros actualizados) txt (43 Kb) pdf (445 Kb) docx (594 Kb)
Leer 39 páginas más »
Disponible sólo en Clubensayos.com