Está en la página 1de 8

Yoberlina

mysql> create database ENMANUEL;

Query OK, 1 row affected (0.00 sec)

mysql> use ENMANUEL;

Database changed

mysql> CREATE TABLE IF NOT EXISTS LUNA(

-> id int(11) NOT NULL AUTO_INCREMENT,

-> NOMBRE varchar(50),

-> APELLIDO varchar(50),

-> PRIMARY KEY (id)

-> );

Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO LUNA (id, NOMBRE, APELLIDO) VALUES ( null, "ENMANUEL", "lugo");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO LUNA (id, NOMBRE, APELLIDO) VALUES ( null, "PEDRO", "MERCEDES");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO LUNA (id, NOMBRE, APELLIDO) VALUES ( null, "JUAN", "Apellido");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO LUNA (id, NOMBRE, APELLIDO) VALUES ( null, "domingo", "perez");

Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO LUNA (id, NOMBRE, APELLIDO) VALUES ( null, "freddy", "joshet");

Query OK, 1 row affected (0.00 sec)

mysql> select*from LUNA;


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

| id | NOMBRE | APELLIDO |

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

| 1 | ENMANUEL | lugo |

| 2 | PEDRO | MERCEDES |

| 3 | JUAN | Apellido |

| 4 | domingo | perez |

| 5 | freddy | joshet |

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

5 rows in set (0.00 sec)

-Eliminar 3 registros de cada tabla.

mysql> delete from LUNA where nombre="yoberlina";

Query OK, 1 row affected (0.00 sec)

mysql> delete from LUNA where nombre="Pedro";

Query OK, 1 row affected (0.00 sec)

mysql> delete from LUNA where nombre="Juan";

Query OK, 1 row affected (0.00 sec)


mysql> select*from LUNA;

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

| id | NOMBRE | APELLIDO |

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

| 4 | domingo | perez |

| 5 | freddy | joshet |

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

2 rows in set (0.01 sec)

| 4 | domingo | JUANSOTO |

| 5 | freddy | joshet |

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

2 rows in set (0.00 sec)

-Actualizar 3 registros de cada tabla.

mysql> Update LUNA set apellido="too" where nombre="freddy";

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> select*from LUNA;

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

| id | NOMBRE | APELLIDO |

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

| 4 | domingo | JUANSOTO |

| 5 | freddy | too |

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

2 rows in set (0.00 sec)


-Editar el nombre de un campo de cada tabla.
mysql> Alter Table LUNA change column APELLIDO PELE varchar(50);

Query OK, 2 rows affected (0.06 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> describe alumnos;

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

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

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

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

| NOMBRE | varchar(50) | YES | | NULL | |

| PELE | varchar(50) | YES | | NULL | |

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

3 rows in set (0.03 sec)

mysql> Alter table LUNA add column APELLIDO varchar(50);

Query OK, 2 rows affected (0.07 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> Alter table LUNA add column NUMERODETELEEOFNO INT;

Query OK, 2 rows affected (0.03 sec)

Records: 2 Duplicates: 0 Warnings: 0


CAMBIAR EL TIPO DE DATO DE UN CAMPO

mysql> create database hola;

Query OK, 1 row affected (0.01 sec)

mysql> CREATE TABLE IF NOT EXISTS FARMACIA (

-> id int(11) NOT NULL AUTO_INCREMENT,

-> nombre varchar(50),

-> PRODUCTO varchar(50),

-> PRIMARY KEY (id)

-> );

Query OK, 0 rows affected (0.02 sec)

mysql> describe farmacia;

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

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

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

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

| nombre | varchar(50) | YES | | NULL | |

| PRODUCTO | varchar(50) | YES | | NULL | |

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

3 rows in set (0.01 sec)

mysql> alter table farmacia modify producto int;

Query OK, 0 rows affected (0.03 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> describe farmacia;

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

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

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

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

| nombre | varchar(50) | YES | | NULL | |


| producto | int(11) | YES | | NULL | |

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

3 rows in set (0.02 sec)

mysql> ^E

Base de dato
mysql> drop table LUNA;

Query OK, 0 rows affected (0.01 sec)

mysql> select*from LUNA;

ERROR 1146 (42S02): Table “enmanuel.luna” doesn't exist

mysql> drop database ENMANUEL;

Query OK, 1 row affected (0.00 sec)


Base de dato estudiante

mysql> create database SERGIOSAD;

Query OK, 1 row affected (0.00 sec)

Database changed

mysql>

mysql> CREATE TABLE IF NOT EXISTS ALUMNOS(

-> id int(11) NOT NULL AUTO_INCREMENT,

-> NOMBRE varchar(50),

-> APELLIDO varchar(50),

-> NOMBRE_DE_LOS_PADRES varchar(50),

-> FECHA_DE_NACIMIENTO varchar(50),

-> PRIMARY KEY (id)

-> );

Query OK, 0 rows affected (0.03 sec)

5 rows in set (0.03 sec)

mysql> insert into alumnos(id, nombre, apellido, nombre_de_los_padres,


fecha_de_nacimiento) values ("1", "yoberlina", "lugo", "anderson_herrera", "1111111");

Query OK, 1 row affected (0.00 sec)

mysql> insert into alumnos(id, nombre, apellido, nombre_de_los_padres,


fecha_de_nacimiento) values ("2", "yoely", "fernandez", "maria", "xxxxx");

Query OK, 1 row affected (0.00 sec)

mysql> select*from aumnos;

ERROR 1146 (42S02): Table 'sergiosad.aumnos' doesn't exist

mysql> select*from alumnos;

+----+-----------+-----------+----------------------+---------------------+
| id | NOMBRE | APELLIDO | NOMBRE_DE_LOS_PADRES | FECHA_DE_NACIMIENTO |

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

| 1 | LUNA | lugo | anderson_herrera | 1111111 |

| 2 | yoely | fernandez | maria | xxxxx |

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

2 rows in set (0.00 sec)

También podría gustarte