Mysgl base de datos

Solo disponible en BuenasTareas
  • Páginas : 5 (1106 palabras )
  • Descarga(s) : 0
  • Publicado : 21 de diciembre de 2010
Leer documento completo
Vista previa del texto
Enter password: ***
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.22-community-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database biblioteca;
Query OK, 1 row affected (0.05 sec)

mysql> use biblioteca;
Database changed
mysql> create table libro (
-> id libro int(4) unsigned notnull,
-> nomlibro varchar(50),
-> autor varchar(50),
-> costo int(3),
-> edicion varchar(35),
-> fechaedic date,
-> primary key(idlibro)
-> );
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 'libro
int(4) unsigned not null,
nomlibro varchar(50),
autorvarchar(50),
costo i' at line 2
mysql> create table libro (
-> idlibro int(4) unsigned not null,
-> nomlibro varchar(50),
-> autor varchar(50),
-> costo int(3),
-> edicion varchar(35),
-> fechaedic date,
-> primary key(idlibro)
-> );
Query OK, 0 rows affected (0.09 sec)

mysql> describe libro;+-----------+-----------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-----------------+------+-----+---------+-------+
| idlibro | int(4) unsigned | NO | PRI | NULL | |
| nomlibro | varchar(50) | YES | | NULL | |
| autor | varchar(50) | YES | | NULL | |
| costo | int(3) | YES | | NULL | |
|edicion | varchar(35) | YES | | NULL | |
| fechaedic | date | YES | | NULL | |
+-----------+-----------------+------+-----+---------+-------+
6 rows in set (0.02 sec)

mysql> insert into libro values(
-> 1000,
-> "el zahir",
-> "paulo coelho",
-> 200,
-> "4ta",
-> "2000-02-22"
-> );
Query OK, 1 row affected (0.05 sec)mysql> insert into libro values(
-> 2000,
-> "los hombres son de marte y las mujeres de venus",
-> "j.mayer",
-> 175,
-> "2da",
-> "2000-08-15"
-> );
Query OK, 1 row affected (0.02 sec)

mysql> insert into libro values(
-> 3000,
-> "el monje que vendio su ferrari",
-> "s.shiffer",
-> 120,
-> "3ra",
-> "2005-02-20"
-> );Query OK, 1 row affected (0.02 sec)

mysql> insert into libro values(
-> 4000,
-> "el vendedor mas grande del mundo",
-> "og mandino",
-> 100,
-> "1ra",
-> "1988-10-10"
-> );
Query OK, 1 row affected (0.02 sec)

mysql> select * from libro order by costo desc;
+---------+-------------------------------------------------+--------------+-------+---------+------------+
| idlibro | nomlibro | autor | cos
to | edicion | fechaedic |
+---------+-------------------------------------------------+--------------+----
---+---------+------------+
| 1000 | el zahir | paulo coelho | 2
00 | 4ta | 2000-02-22 |
| 2000 | los hombres son de marte y las mujeresde venus | j.mayer | 1
75 | 2da | 2000-08-15 |
| 3000 | el monje que vendio su ferrari | s.shiffer | 1
20 | 3ra | 2005-02-20 |
| 4000 | el vendedor mas grande del mundo | og mandino | 1
00 | 1ra | 1988-10-10 |
+---------+-------------------------------------------------+--------------+----
---+---------+------------+
4 rowsin set (0.02 sec)

mysql> select from libro;
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 'from
libro' at line 1
mysql> select * from libro;
+---------+-------------------------------------------------+--------------+----
---+---------+------------+
| idlibro | nomlibro...
tracking img