Você está na página 1de 3

Enter password: ****

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 3
Server version: 5.1.40-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| mibase
|
| mysql
|
| test
|
+--------------------+
4 rows in set (0.00 sec)
mysql> use mibase
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> create table clientes(rut varchar(10) not null primary key,nombre varchar
(50) null , telefono int);
Query OK, 0 rows affected (0.03 sec)
mysql> show tables;
+------------------+
| Tables_in_mibase |
+------------------+
| clientes
|
+------------------+
1 row in set (0.00 sec)
mysql> describe clientes
-> ;
+----------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| rut
| varchar(10) | NO | PRI | NULL
|
|
| nombre | varchar(50) | YES |
| NULL
|
|
| telefono | int(11)
| YES |
| NULL
|
|
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql> create table Productos (codigo int not null primary key,
-> nombre varchar(50) not null,
-> descripcion varchar(50) not default="nn"
-> ,precio int);
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 'defau
lt="nn"
,precio int)' at line 3
mysql> create table Productos (codigo int not null primary key,
-> nombre varchar(50) not null,
-> descripcion varchar(50) not default="nn"
-> ,precio int);
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 'defau

lt="nn"
,precio int)' at line 3
mysql> create table Productos (codigo int not null primary key,
-> nombre varchar(50) not null,
-> descripcion varchar(50) default="nn"
->
-> ;
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 '="nn"
' at line 3
mysql> create table Productos (codigo int not null primary key,
-> nombre varchar(50) not null,
-> descripcion varchar(50) default "nn",
-> precio int);
Query OK, 0 rows affected (0.04 sec)
mysql> describe productos
-> ;
+-------------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| codigo
| int(11)
| NO | PRI | NULL
|
|
| nombre
| varchar(50) | NO |
| NULL
|
|
| descripcion | varchar(50) | YES |
| nn
|
|
| precio
| int(11)
| YES |
| NULL
|
|
+-------------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> create table categorias(codigo int,nombre varchar(50) not null,primary ke
y(codigo));
Query OK, 0 rows affected (0.04 sec)
mysql> show tables
-> ;
+------------------+
| Tables_in_mibase |
+------------------+
| categorias
|
| clientes
|
| productos
|
+------------------+
3 rows in set (0.00 sec)
mysql> alter table clientes rename personal;
Query OK, 0 rows affected (0.03 sec)
mysql> show tables;
+------------------+
| Tables_in_mibase |
+------------------+
| categorias
|
| personal
|
| productos
|
+------------------+
3 rows in set (0.01 sec)
mysql> describe personal;
+----------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+

| rut
| varchar(10) | NO | PRI | NULL
|
|
| nombre | varchar(50) | YES |
| NULL
|
|
| telefono | int(11)
| YES |
| NULL
|
|
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql> alter table personal change nombre rename nombrecompleto varchar(50);
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 'renam
e nombrecompleto varchar(50)' at line 1
mysql> alter table personal change nombre nombrecompleto varchar(50);
Query OK, 0 rows affected (2.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe personal;
+----------------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| rut
| varchar(10) | NO | PRI | NULL
|
|
| nombrecompleto | varchar(50) | YES |
| NULL
|
|
| telefono
| int(11)
| YES |
| NULL
|
|
+----------------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql> alter table personal change nombrecompleto nombrecompleto varchar(80);
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe personal;
+----------------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| rut
| varchar(10) | NO | PRI | NULL
|
|
| nombrecompleto | varchar(80) | YES |
| NULL
|
|
| telefono
| int(11)
| YES |
| NULL
|
|
+----------------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql> alter table personal change nombrecompleto nombre varchar(80);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table personal change nombre nombre varchar(80) not null;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> describe personal;
+----------+-------------+------+-----+---------+-------+
| Field
| Type
| Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| rut
| varchar(10) | NO | PRI | NULL
|
|
| nombre | varchar(80) | NO |
| NULL
|
|
| telefono | int(11)
| YES |
| NULL
|
|
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)
mysql>

Você também pode gostar