Sei sulla pagina 1di 6

mysql> show databases;

+--------------------+
| Database |
+--------------------+
| information_schema |
| minimarket |
| mysql |
| performance_schema |
| test |
| veterinaria |
+--------------------+
6 rows in set (0.00 sec)

mysql> use minimarket;


Database changed
mysql> create table empleado
-> (id_empleado int(11) primary key,
-> nombre varchar(30),
-> apellidos varchar(30),
-> f_nacimiento date,
-> sexo varchar(1),
-> cargo varchar(15),
-> salario float;
describe empleado;
+--------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| id_empleado | int(11) | NO | PRI | NULL | |
| nombre | varchar(30) | YES | | NULL | |
| apellidos | varchar(30) | YES | | NULL | |
| f_nacimiento | date | YES | | NULL | |
| sexo | varchar(1) | YES | | NULL | |
| cargo | varchar(15) | YES | | NULL | |
| salario | float | YES | | NULL | |
+--------------+-------------+------+-----+---------+-------+
mysql> insert into empleado
-> values('2','Rosa','Gonzalo','1990-05-12','f','Veterinaria','2500');
Query OK, 1 row affected (0.04 sec)

mysql> insert into empleado


-> values('3','manuel','Gutierrez','1985-11-12','M','Veterinaria','2800');
Query OK, 1 row affected (0.05 sec)

mysql> insert into empleado


-> values('4','Erika','Maldonado','1994-05-30','M','Veterinaria','1200');
Query OK, 1 row affected (0.03 sec)

modificar bd
mysql> update empleado set cargo='secretaria' where id_empleado=4;
Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0

...................................................................................
..........................
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.5.24-log 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 |
| minimarket |
| mysql |
| performance_schema |
| test |
| veterinaria |
+--------------------+
6 rows in set (0.00 sec)

mysql> use minimarket;


Database changed
mysql> create table empleado
-> (id_empleado int(11) primary key,
-> nombre varchar(30),
-> apellidos varchar(30),
-> f_nacimiento date,
-> sexo varchar(1),
-> cargo varchar(15),
-> salario float));
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 ')' at
line 8
mysql> salario float;
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 'salario
float' at line 1
mysql> create table empleado
-> (id_empleado int(11) primary key,
-> nombre varchar(30),
-> apellidos varchar(30),
-> f_nacimiento date,
-> sexo varchar(1),
-> cargo varchar(15),
-> salario float;
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 '' at
line 8
mysql> create table empleado
-> (id_empleado int(11) primary key,
-> nombre varchar(30),
-> apellidos varchar(30),
-> f_nacimiento date,
-> sexo varchar(1),
-> cargo varchar(15),
-> salario float;
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 '' at
line 8
mysql> create table empleado
-> (id_empleado int(11) primary key,
-> nombre varchar(30),
-> apellidos varchar(30),
-> f_nacimiento date,
-> sexo varchar(1),
-> cargo varchar(15),
-> salario float);
Query OK, 0 rows affected (0.04 sec)

mysql> insert into empleado


-> select from empleado;
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 'from
empleado' at line 2
mysql> select * from empleado;
Empty set (0.00 sec)

mysql> describe empleado;


+--------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| id_empleado | int(11) | NO | PRI | NULL | |
| nombre | varchar(30) | YES | | NULL | |
| apellidos | varchar(30) | YES | | NULL | |
| f_nacimiento | date | YES | | NULL | |
| sexo | varchar(1) | YES | | NULL | |
| cargo | varchar(15) | YES | | NULL | |
| salario | float | YES | | NULL | |
+--------------+-------------+------+-----+---------+-------+
7 rows in set (0.02 sec)

mysql> insert into empleado;


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 '' at
line 1
mysql> insert into empleado
-> values('1','Carlos','Jimenes','1985-05-03','M','oficinista','1500');
Query OK, 1 row affected (0.06 sec)

mysql> values('2','Rosa','Gonzalo','1990-05-12','f','Veterinaria','2500');
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
'values('2','Rosa','Gonzalo','1990-05-12','f','Veterinaria','2500')' at line 1
mysql> values('2','Rosa','Gonzales','1990-05-12','f','Veterinaria','2500');
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
'values('2','Rosa','Gonzales','1990-05-12','f','Veterinaria','2500')' at line 1
mysql> insert into empleado
-> values('2','Rosa','Gonzalo','1990-05-12','f','Veterinaria','2500');
Query OK, 1 row affected (0.04 sec)

mysql> insert into empleado


-> values('3','manuel','Gutierrez','1985-11-12','M','Veterinaria','2800');
Query OK, 1 row affected (0.05 sec)
mysql> insert into empleado
-> values('4','Erika','Maldonado','1994-05-30','M','Veterinaria','1200');
Query OK, 1 row affected (0.03 sec)

mysql> insert into empleado


-> values('5','Rub�n','Casimiro','1990-02-01','M','Empleado','1600');
Query OK, 1 row affected (0.06 sec)

mysql> update empleado set cargo='secretaria' where id_empleado=4;


Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from empleado


-> select * from empleado;
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 'select *
from empleado' at line 2
mysql> select * from empleado;
+-------------+--------+-----------+--------------+------+-------------+---------+
| id_empleado | nombre | apellidos | f_nacimiento | sexo | cargo | salario |
+-------------+--------+-----------+--------------+------+-------------+---------+
| 1 | Carlos | Jimenes | 1985-05-03 | M | oficinista | 1500 |
| 2 | Rosa | Gonzalo | 1990-05-12 | f | Veterinaria | 2500 |
| 3 | manuel | Gutierrez | 1985-11-12 | M | Veterinaria | 2800 |
| 4 | Erika | Maldonado | 1994-05-30 | M | secretaria | 1200 |
| 5 | Rub�n | Casimiro | 1990-02-01 | M | Empleado | 1600 |
+-------------+--------+-----------+--------------+------+-------------+---------+
5 rows in set (0.00 sec)

mysql> select sexo, count(*) as empleado


-> from empleado
-> group by sexo;
+------+----------+
| sexo | empleado |
+------+----------+
| f | 1 |
| M | 4 |
+------+----------+
2 rows in set (0.00 sec)

mysql> update empleado set sexo='f' where id_empleado=4;


Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select sexo, count(*) as empleado


-> from empleado
-> group by sexo;
+------+----------+
| sexo | empleado |
+------+----------+
| f | 2 |
| M | 3 |
+------+----------+
2 rows in set (0.00 sec)

mysql> select cargo, count(*) as empleado


-> from empleado
-> group by cargo;
+-------------+----------+
| cargo | empleado |
+-------------+----------+
| Empleado | 1 |
| oficinista | 1 |
| secretaria | 1 |
| Veterinaria | 2 |
+-------------+----------+
4 rows in set (0.00 sec)

mysql> select sexo,sum(salario)as Total


-> from empleado
-> group by sexo;
+------+-------+
| sexo | Total |
+------+-------+
| f | 3700 |
| M | 5900 |
+------+-------+
2 rows in set (0.00 sec)

mysql> select cargo,sum(salario) as Total


-> from empleado
-> group by cargo;
+-------------+-------+
| cargo | Total |
+-------------+-------+
| Empleado | 1600 |
| oficinista | 1500 |
| secretaria | 1200 |
| Veterinaria | 5300 |
+-------------+-------+
4 rows in set (0.00 sec)

mysql> select distint cargo


-> from empleado;
ERROR 1054 (42S22): Unknown column 'distint' in 'field list'
mysql> select distinct cargo
-> from empleado;
+-------------+
| cargo |
+-------------+
| oficinista |
| Veterinaria |
| secretaria |
| Empleado |
+-------------+
4 rows in set (0.00 sec)

mysql> select distinct sexo


-> from empleado;
+------+
| sexo |
+------+
| M |
| f |
+------+
2 rows in set (0.00 sec)

mysql>

Potrebbero piacerti anche