martes, 23 de junio de 2015

Heteroevaluacion 2.1


EJERCICIO 1

Enter password: ****

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

Your MySQL connection id is 4

Server version: 5.0.51b-community-nt-log MySQL Community Edition (GPL)

 

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 

mysql> create database MATERIA_PRIMA;

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

mysql> create database materiia_prima;

Query OK, 1 row affected (0.00 sec)

 

mysql> use materia_prima;

Database changed

mysql> create table productos(CODIGO varchar(20) primary key,NOMBRE varchar(35),PRECIO integer,FECHA_DE_COMPRA date);

Query OK, 0 rows affected (0.08 sec)

 

mysql> insert into productos values('A01','Vinos',250,2009/11/02);

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

 

mysql> insert into productos values('A02','Silla modelo.zaz',200,2009/11/03);

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

 

mysql> insert into productos values('A03','Silla modelo.xax',400,2009/11/03);

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

 

mysql> insert into productos values('A04','mesa cuadrada',650,2009/11/05);

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

 

mysql> insert into productos values('A05','vagilla',750,2009/11/05);

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

 

mysql> select * from productos;

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

| CODIGO | NOMBRE           | PRECIO | FECHA_DE_COMPRA |

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

| A01    | Vinos            |    250 | 0000-00-00      |

| A02    | Silla modelo.zaz |    200 | 0000-00-00      |

| A03    | Silla modelo.xax |    400 | 0000-00-00      |

| A04    | mesa cuadrada    |    650 | 0000-00-00      |

| A05    | vagilla          |    750 | 0000-00-00      |

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

5 rows in set (0.00 sec)

 

mysql> select * from productos where nombre='Vinos';

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

| CODIGO | NOMBRE | PRECIO | FECHA_DE_COMPRA |

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

| A01    | Vinos  |    250 | 0000-00-00      |

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

1 row in set (0.02 sec)

 

mysql> select * from productos where nombre like'S%';:

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

| CODIGO | NOMBRE           | PRECIO | FECHA_DE_COMPRA |

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

| A02    | Silla modelo.zaz |    200 | 0000-00-00      |

| A03    | Silla modelo.xax |    400 | 0000-00-00      |

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

2 rows in set (0.01 sec)

mysql> select * from productos where precio >430;

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

| CODIGO | NOMBRE        | PRECIO | FECHA_DE_COMPRA |

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

| A04    | mesa cuadrada |    650 | 0000-00-00      |

| A05    | vagilla       |    750 | 0000-00-00      |

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

2 rows in set (0.00 sec)

 
mysql> select avg(precio) from productos where left(nombre,5)='vagilla';

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

| avg(precio) |

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

|        NULL |

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

1 row in set (0.00 sec)


mysql> alter table productos add categoria varchar (10)

    -> ;

Query OK, 5 rows affected (0.17 sec)

Records: 5  Duplicates: 0  Warnings: 0

 

EJERCICIO 3

Enter password: ****

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

Your MySQL connection id is 6

Server version: 5.0.51b-community-nt-log MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


mysql> create database producto1;

Query OK, 1 row affected (0.00 sec)


mysql> use producto1;

Database changed

mysql> create table productos(codigo varchar(3) primary key,nombre varchar(30),precio decimal(6,2),fechaalta date);

Query OK, 0 rows affected (0.11 sec)


mysql> insert into productos values('a01','Afilador',2.50,'2007-11-02');

Query OK, 1 row affected (0.02 sec)


mysql> insert into productos values('a02','Silla mod.ZAZ',20,'2007-11-03');

Query OK, 1 row affected (0.00 sec)
 
mysql> insert into productos values('s02','Silla mod.XAX',25,'2007-11-03');

Query OK, 1 row affected (0.00 sec)


mysql> insert into productos values('s01','Silla mod.ZAZ',20,'2007-11-03');

Query OK, 1 row affected (0.00 sec)

No hay comentarios.:

Publicar un comentario