mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | cdcol | | fechas | | libreria | | mysql | | notas | | performance_schema | | phpmyadmin | | test | | webauth | +--------------------+ 10 rows in set (0.02 sec) mysql> use fechas; Database changed mysql> create table ejercicio -> (codigo char(10) primary key,nombre char(30), sexo char(10), nacimiento date, hijos char(2)); Query OK, 0 rows affected (0.19 sec) mysql> describe ejercicio; +------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+----------+------+-----+---------+-------+ | codigo | char(10) | NO | PRI | NULL | | | nombre | char(30) | YES | | NULL | | | sexo | char(10) | YES | | NULL | | | nacimiento | date | YES | | NULL | | | hijos | char(2) | YES | | NULL | | +------------+----------+------+-----+---------+-------+ 5 rows in set (0.02 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('22663355','Angel Cuadrado','hombre','1966-05-13','0'); Query OK, 1 row affected (0.03 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('1188996633','Yoreida Maria','Mujer','1978-03-05','2'); Query OK, 1 row affected (0.05 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('4488663322','Jorge Fuentes','Hombre','1980-06-22','2'); Query OK, 1 row affected (0.04 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('0022559966','Eder Pulgar','Hombre','1960-02-20','6'); Query OK, 1 row affected (0.03 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('08225599666','Mariana Gonzalez','Mujer','1982-03-24','1'); Query OK, 1 row affected, 1 warning (0.07 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('556959966','Angela Ruiz','Mujer','1977-11-15','1'); Query OK, 1 row affected (0.09 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('0028957446','Juan Carlos Serpa','Hombre','1982-11-25','2'); Query OK, 1 row affected (0.05 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('9999957446','Carlota Sonora','Mujer','1985-11-03','4'); Query OK, 1 row affected (0.06 sec) mysql> select * from ejercicio; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0022559966 | Eder Pulgar | Hombre | 1960-02-20 | 6 | | 0028957446 | Juan Carlos Serpa | Hombre | 1982-11-25 | 2 | | 0822559966 | Mariana Gonzalez | Mujer | 1982-03-24 | 1 | | 1188996633 | Yoreida Maria | Mujer | 1978-03-05 | 2 | | 22663355 | Angel Cuadrado | hombre | 1966-05-13 | 0 | | 4488663322 | Jorge Fuentes | Hombre | 1980-06-22 | 2 | | 556959966 | Angela Ruiz | Mujer | 1977-11-15 | 1 | | 9999957446 | Carlota Sonora | Mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 8 rows in set (0.02 sec) mysql> select current_date(); +----------------+ | current_date() | +----------------+ | 2015-10-30 | +----------------+ 1 row in set (0.07 sec) mysql> select year (current_date()); +-----------------------+ | year (current_date()) | +-----------------------+ | 2015 | +-----------------------+ 1 row in set (0.01 sec) mysql> select month(current_date()); +-----------------------+ | month(current_date()) | +-----------------------+ | 10 | +-----------------------+ 1 row in set (0.02 sec) mysql> select day(current_date()); +---------------------+ | day(current_date()) | +---------------------+ | 30 | +---------------------+ 1 row in set (0.01 sec) mysql> select date_add(current_date(),interval 15 day); +------------------------------------------+ | date_add(current_date(),interval 15 day) | +------------------------------------------+ | 2015-11-14 | +------------------------------------------+ 1 row in set (0.00 sec) mysql> select date_add(current_date(),interval 3 month); +-------------------------------------------+ | date_add(current_date(),interval 3 month) | +-------------------------------------------+ | 2016-01-30 | +-------------------------------------------+ 1 row in set (0.00 sec) mysql> select date_add(current_date(),interval 5 year); +------------------------------------------+ | date_add(current_date(),interval 5 year) | +------------------------------------------+ | 2020-10-30 | +------------------------------------------+ 1 row in set (0.00 sec) mysql> select datediff(current_date(),'1994-05-03'); +---------------------------------------+ | datediff(current_date(),'1994-05-03') | +---------------------------------------+ | 7850 | +---------------------------------------+ 1 row in set (0.06 sec) mysql> select nombre,year(current_date())-year(nacimiento) from ejercicio; +-------------------+---------------------------------------+ | nombre | year(current_date())-year(nacimiento) | +-------------------+---------------------------------------+ | Eder Pulgar | 55 | | Juan Carlos Serpa | 33 | | Mariana Gonzalez | 33 | | Yoreida Maria | 37 | | Angel Cuadrado | 49 | | Jorge Fuentes | 35 | | Angela Ruiz | 38 | | Carlota Sonora | 30 | +-------------------+---------------------------------------+ 8 rows in set (0.01 sec) mysql> select nombre from ejercicio where sexo='mujer' and nombre like '%a'; +----------------+ | nombre | +----------------+ | Yoreida Maria | | Carlota Sonora | +----------------+ 2 rows in set (0.05 sec) mysql> select count(*)from ejercicio where sexo='mujer' and nombre like '%a'; +----------+ | count(*) | +----------+ | 2 | +----------+ 1 row in set (0.02 sec) mysql> select count(*) from ejercicio where year(nacimiento) between '1960'and 1 -> ; +----------+ | count(*) | +----------+ | 0 | +----------+ 1 row in set (0.01 sec) mysql> select count(*) from ejercicio where year (nacimiento) between '1960' and 1969; +----------+ | count(*) | +----------+ | 2 | +----------+ 1 row in set (0.00 sec) mysql> select * from ejercicio where year (current_date())-year(nacimiento) between '28' and '33'; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0028957446 | Juan Carlos Serpa | Hombre | 1982-11-25 | 2 | | 0822559966 | Mariana Gonzalez | Mujer | 1982-03-24 | 1 | | 9999957446 | Carlota Sonora | Mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 3 rows in set (0.01 sec) mysql> select sum(hijos) from ejercicio; +------------+ | sum(hijos) | +------------+ | 18 | +------------+ 1 row in set (0.04 sec) mysql> select hijos, count(*) from ejercicio group by hijos; +-------+----------+ | hijos | count(*) | +-------+----------+ | 0 | 1 | | 1 | 2 | | 2 | 3 | | 4 | 1 | | 6 | 1 | +-------+----------+ 5 rows in set (0.04 sec) mysql> select count(*) from ejercicio where year(current_date)-year(nacimiento)<=28 and sexo='mujer'; +----------+ | count(*) | +----------+ | 0 | +----------+ 1 row in set (0.00 sec) mysql> create view ejercicio as select * from ejercicio where nombre like'%a'; ERROR 1050 (42S01): Table 'ejercicio' already exists mysql> create view nombre as select * from ejercicio where nombre like'%a'; Query OK, 0 rows affected (0.09 sec) mysql> create view ejerciciosexo as select * from ejercicio where sexo= 'hombre'; Query OK, 0 rows affected (0.04 sec) mysql> select * from ejercicio; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0022559966 | Eder Pulgar | Hombre | 1960-02-20 | 6 | | 0028957446 | Juan Carlos Serpa | Hombre | 1982-11-25 | 2 | | 0822559966 | Mariana Gonzalez | Mujer | 1982-03-24 | 1 | | 1188996633 | Yoreida Maria | Mujer | 1978-03-05 | 2 | | 22663355 | Angel Cuadrado | hombre | 1966-05-13 | 0 | | 4488663322 | Jorge Fuentes | Hombre | 1980-06-22 | 2 | | 556959966 | Angela Ruiz | Mujer | 1977-11-15 | 1 | | 9999957446 | Carlota Sonora | Mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 8 rows in set (0.00 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('8005129','Alberto Lechona','hombre','1970-03-22','1'); Query OK, 1 row affected (0.03 sec) mysql> select * from ejercicio; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0022559966 | Eder Pulgar | Hombre | 1960-02-20 | 6 | | 0028957446 | Juan Carlos Serpa | Hombre | 1982-11-25 | 2 | | 0822559966 | Mariana Gonzalez | Mujer | 1982-03-24 | 1 | | 1188996633 | Yoreida Maria | Mujer | 1978-03-05 | 2 | | 22663355 | Angel Cuadrado | hombre | 1966-05-13 | 0 | | 4488663322 | Jorge Fuentes | Hombre | 1980-06-22 | 2 | | 556959966 | Angela Ruiz | Mujer | 1977-11-15 | 1 | | 8005129 | Alberto Lechona | hombre | 1970-03-22 | 1 | | 9999957446 | Carlota Sonora | Mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 9 rows in set (0.00 sec) mysql> drop view ejerciciosexo; Query OK, 0 rows affected (0.01 sec) mysql> select * from ejercicio; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0022559966 | Eder Pulgar | Hombre | 1960-02-20 | 6 | | 0028957446 | Juan Carlos Serpa | Hombre | 1982-11-25 | 2 | | 0822559966 | Mariana Gonzalez | Mujer | 1982-03-24 | 1 | | 1188996633 | Yoreida Maria | Mujer | 1978-03-05 | 2 | | 22663355 | Angel Cuadrado | hombre | 1966-05-13 | 0 | | 4488663322 | Jorge Fuentes | Hombre | 1980-06-22 | 2 | | 556959966 | Angela Ruiz | Mujer | 1977-11-15 | 1 | | 8005129 | Alberto Lechona | hombre | 1970-03-22 | 1 | | 9999957446 | Carlota Sonora | Mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 9 rows in set (0.00 sec) mysql> mysqldump -B -urrot -p fechas>D:\fechas.sql ERROR: Unknown command '\f'. -> ; 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 'mysqldump -B -urrot -p fechas>D:\fechas.sql' at line 1 mysql> mysqldump -B -urrot -p fechas> D:\fechas.sql ERROR: Unknown command '\f'. -> mysqldump -B -urrot -p fechas>D:\clase24oct.sql -> ; 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 'lase24oct.sql' at line 1 mysql> exit