Taller Auto_Incremento

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cdcol              |
| colegio            |
| libreria           |
| mysql              |
| performance_schema |
| phpmyadmin         |
| test               |
| webauth            |
+--------------------+
9 rows in set (0.11 sec)
 
 
mysql> create database autoincremento;
Query OK, 1 row affected (0.02 sec)
 
mysql> use autoincremento;
Database changed
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| autoincremento     |
| cdcol              |
| colegio            |
| libreria           |
| mysql              |
| performance_schema |
| phpmyadmin         |
| test               |
| webauth            |
+--------------------+
10 rows in set (0.00 sec)
 
 
mysql> create table edicion(codigo int auto_increment not null primary key,
    -> descripcion char(30) not null);
Query OK, 0 rows affected (0.38 sec)
 
mysql> show tables;
+--------------------------+
| Tables_in_autoincremento |
+--------------------------+
| edicion                  |
+--------------------------+
1 row in set (0.00 sec)
 
mysql> describe edicion;
+-------------+----------+------+-----+---------+----------------+
| Field       | Type     | Null | Key | Default | Extra          |
+-------------+----------+------+-----+---------+----------------+
| codigo      | int(11)  | NO   | PRI | NULL    | auto_increment |
| descripcion | char(30) | NO   |     | NULL    |                |
+-------------+----------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
 
mysql> use autoincremento;
Database changed
mysql> show tables;
+--------------------------+
| Tables_in_autoincremento |
+--------------------------+
| edicion                  |
+--------------------------+
1 row in set (0.00 sec)
 
mysql> describe edicion;
+-------------+----------+------+-----+---------+----------------+
| Field       | Type     | Null | Key | Default | Extra          |
+-------------+----------+------+-----+---------+----------------+
| codigo      | int(11)  | NO   | PRI | NULL    | auto_increment |
| descripcion | char(30) | NO   |     | NULL    |                |
+-------------+----------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
 
mysql> select * from edicion;
Empty set (0.00 sec)
 
mysql> insert into edicion (descripcion) values ('primera vuelta');
Query OK, 1 row affected (0.03 sec)
 
mysql> insert into edicion (descripcion) values ('segunda vuelta');
Query OK, 1 row affected (0.06 sec)
 
mysql> insert into edicion (descripcion) values ('tercera vuelta');
Query OK, 1 row affected (0.03 sec)
 
mysql> select * from edicion;
+--------+----------------+
| codigo | descripcion    |
+--------+----------------+
|      1 | primera vuelta |
|      2 | segunda vuelta |
|      3 | tercera vuelta |
+--------+----------------+
3 rows in set (0.00 sec)
 
mysql> delete from edicion where codigo=1;
Query OK, 1 row affected (0.05 sec)
 
mysql> delete from edicion;
Query OK, 2 rows affected (0.05 sec)
 
mysql> select * from edicion;
Empty set (0.00 sec)
 
mysql> truncate table edicion;
Query OK, 0 rows affected (0.19 sec)
 
mysql> exit