Query OK, 1 row affected (0.09 sec)
mysql> use empleados
Database changed
mysql> create table emp(RFC char(9),Nombre char(15),ApePaterno char(15),ApeMater
no char(15),Edad date, Puesto int(5));
Query OK, 0 rows affected (0.07 sec)
mysql> insert into emp values('EDFT56789','Juan','Perez','Hernandez','1985-03-15
','30245');
Query OK, 1 row affected (0.06 sec)
mysql> insert into emp values('HYIM2861','Pedro','Gomez','lopez','1983-09-02','5
2148');
Query OK, 1 row affected (0.02 sec)
mysql> insert into emp values('ECYO48623','Pablo','Justo','Herrera','1982-11-15'
,'78952');
Query OK, 1 row affected (0.03 sec)
mysql> describe emp;
+------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+-------+
| RFC | char(9) | NO | PRI | NULL | |
| Nombre | char(15) | YES | | NULL | |
| ApePaterno | char(15) | YES | | NULL | |
| ApeMaterno | char(15) | YES | | NULL | |
| Edad | date | YES | | NULL | |
| Puesto | int(5) | YES | | NULL | |
+------------+----------+------+-----+---------+-------+
6 rows in set (0.08 sec)
mysql> select*from emp;
+-----------+--------+------------+------------+------------+--------+
| RFC | Nombre | ApePaterno | ApeMaterno | Edad | Puesto |
+-----------+--------+------------+------------+------------+--------+
| EDFT56789 | Juan | Perez | Hernandez | 1985-03-15 | 30245 |
| HYIM2861 | Pedro | Gomez | lopez | 1983-09-02 | 52148 |
| ECYO48623 | Pablo | Justo | Herrera | 1982-11-15 | 78952 |
+-----------+--------+------------+------------+------------+--------+
3 rows in set (0.00 sec)
mysql> alter table emp drop puesto;
Query OK, 3 rows affected (0.16 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select*from emp;
+-----------+--------+------------+------------+------------+
| RFC | Nombre | ApePaterno | ApeMaterno | Edad |
+-----------+--------+------------+------------+------------+
| ECYO48623 | Pablo | Justo | Herrera | 1982-11-15 |
| EDFT56789 | Juan | Perez | Hernandez | 1985-03-15 |
| HYIM2861 | Pedro | Gomez | lopez | 1983-09-02 |
+-----------+--------+------------+------------+------------+
3 rows in set (0.00 sec)
mysql> alter table emp add salario int;
Query OK, 3 rows affected (0.29 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select*from emp;
+-----------+--------+------------+------------+------------+---------+
| RFC | Nombre | ApePaterno | ApeMaterno | Edad | salario |
+-----------+--------+------------+------------+------------+---------+
| ECYO48623 | Pablo | Justo | Herrera | 1982-11-15 | NULL |
| EDFT56789 | Juan | Perez | Hernandez | 1985-03-15 | NULL |
| HYIM2861 | Pedro | Gomez | lopez | 1983-09-02 | NULL |
+-----------+--------+------------+------------+------------+---------+
3 rows in set (0.00 sec)
mysql> update emp set salario= '5000' where RFC='ECYO48623';
Query OK, 0 rows affected (0.03 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> update emp set salario= '8000' where RFC='HYIM2861';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update emp set salario= '7850' where RFC='EDFT56789';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select*from emp;
+-----------+--------+------------+------------+------------+---------+
| RFC | Nombre | ApePaterno | ApeMaterno | Edad | salario |
+-----------+--------+------------+------------+------------+---------+
| ECYO48623 | Pablo | Justo | Herrera | 1982-11-15 | 5000 |
| EDFT56789 | Juan | Perez | Hernandez | 1985-03-15 | 7850 |
| HYIM2861 | Pedro | Gomez | lopez | 1983-09-02 | 8000 |
+-----------+--------+------------+------------+------------+---------+
3 rows in set (0.00 sec)
mysql>ALTER TABLE emp CHANGE column salario actividad CHAR(30);
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>select*from emp;
+-----------+--------+------------+------------+------------+-----------+
| RFC | Nombre | ApePaterno | ApeMaterno | Edad | Actividad |
+-----------+--------+------------+------------+------------+-----------+
| ECYO48623 | Pablo | Justo | Herrera | 1982-11-15 | 5000 |
| EDFT56789 | Juan | Perez | Hernandez | 1985-03-15 | 7850 |
| HYIM2861 | Pedro | Gomez | lopez | 1983-09-02 | 8000 |
+-----------+--------+------------+------------+------------+-----------+
3 rows in set (0.00 sec)
mysql> update emp set actividad= 'Directivo' where RFC='ECYO48623';
Query OK, 0 rows affected (0.03 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> update emp set actividad= 'Capturador' where RFC='HYIM2861';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update emp set actividad= 'Administrativo' where RFC='EDFT56789';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select*from emp;
+-----------+--------+------------+------------+------------+----------------+
| RFC | Nombre | ApePaterno | ApeMaterno | Edad | actividad |
+-----------+--------+------------+------------+------------+----------------+
| ECYO48623 | Pablo | Justo | Herrera | 1982-11-15 | Directivo |
| EDFT56789 | Juan | Perez | Hernandez | 1985-03-15 | Administrativo |
| HYIM2861 | Pedro | Gomez | lopez | 1983-09-02 | Capturador |
+-----------+--------+------------+------------+------------+----------------+
3 rows in set (0.00 sec)
mysql> update emp set Nombre='Miguel' where Nombre='Pablo';
Query OK, 1 row affected (0.11 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select*from emp;
+-----------+--------+------------+------------+------------+----------------+
| RFC | Nombre | ApePaterno | ApeMaterno | Edad | actividad |
+-----------+--------+------------+------------+------------+----------------+
| ECYO48623 | Pablo | Justo | Herrera | 1982-11-15 | Directivo |
| EDFT56789 | Miguel | Perez | Hernandez | 1985-03-15 | Administrativo |
| HYIM2861 | Pedro | Gomez | lopez | 1983-09-02 | Capturador |
+-----------+--------+------------+------------+------------+----------------+
3 rows in set (0.00 sec)
mysql> delete from emp where RFC='HYIM2861';
Query OK, 1 row affected (0.03 sec)
mysql> select*from emp;
+-----------+--------+------------+------------+------------+----------------+
| RFC | Nombre | ApePaterno | ApeMaterno | Edad | actividad |
+-----------+--------+------------+------------+------------+----------------+
| ECYO48623 | Pablo | Justo | Herrera | 1982-11-15 | Directivo |
| EDFT56789 | Miguel | Perez | Hernandez | 1985-03-15 | Administrativo |
+-----------+--------+------------+------------+------------+----------------+
2 rows in set (0.00 sec)
mysql> drop table emp;
Query OK, 0 rows affected (0.02 sec)
mysql> select*from emp;
ERROR 1146 (42S02): Table 'empleados.emp' doesn't exist
mysql> Jayro Hannibal Barreda (Jay-bs)
MrtaVero
Suave MtraVero no dijo eliminar Base de datos, pero si les cae gordo la base de datos Empleados denle:
mysql> drop database empleados; mysql> exit
PD1: Saquen los chocolates...
PD2: Hay se ve que me equivoque en alguna linea ¡jajaja!
No hay comentarios:
Publicar un comentario