Vous êtes sur la page 1sur 5

Setting environment for using XAMPP for Windows.

Aprendiz@SENA-PC c:\xampp

# CREATE DATABASE ALMACEN;

"CREATE" no se reconoce como un comando interno o externo,

programa o archivo por lotes ejecutable.

Aprendiz@SENA-PC c:\xampp

# mysql -u root -p

Enter password:

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

Your MySQL connection id is 1

Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

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

| Database |
+--------------------+

| information_schema |

| autos |

| cdcol |

| colegio |

| evaluacion |

| merkasur |

| mysql |

| performance_schema |

| phpmyadmin |

| prueba |

| prueba2 |

| test |

| webauth |

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

13 rows in set (0.01 sec)

mysql> create database ALMACEN;

Query OK, 1 row affected (0.00 sec)

mysql> USE ALMACEN

Database changed

mysql> CREATE TABLE FABRICANTES(ID_FABRICANTE INT NOT NULL PRIMARY KEY,NOMBRE_FAB


VARCHAR (30),DESCRIPCION VARCHAR(30));

Query OK, 0 rows affected (0.38 sec)


mysql> SHOW TABLE

-> SHOW TABLES

-> DESCRIBE

-> SHOW DESCRIBE

SHOW TABLES;

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

| Tables_in_almacen |

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

| fabricantes |

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

1 row in set (0.00 sec)

mysql> CREATE TABLE ARTICULO (ID_ARTICULO INT NOT NULL PRIMARY KEY, NOMBRE_ART
VARCHAR (30), PRECIO INT NOT NULL, ID_FABRICANTE INT FOREIGN KEY(ID_FABRICANTE) RE

FERENCES FABRICANTES(ID_FABRICANTE));

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 'FOREIG

N KEY(ID_FABRICANTE) REFERENCES FABRICANTES(ID_FABRICANTE))' at line 1

mysql> DESCRIBE ARTICULO;

ERROR 1146 (42S02): Table 'almacen.articulo' doesn't exist

mysql> DESCRIBE FABRICANTES;

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

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

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

| ID_FABRICANTE | int(11) | NO | PRI | NULL | |

| NOMBRE_FAB | varchar(30) | YES | | NULL | |


| DESCRIPCION | varchar(30) | YES | | NULL | |

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

3 rows in set (0.05 sec)

mysql> CREATE TABLE ARTICULO

-> (

-> ID_ARTICULO INT PRIMARY KEY NOT NULL, ID_FABRICANTE int, foreign key (ID_FABRICANTE)
REFERENCES FABRICANTES(ID_FABRICANTE), NOMBRE VARCHAR(30) NOT NULL, P

RECIO INT NOT NULL);

Query OK, 0 rows affected (0.45 sec)

mysql> SHOW TABLES;

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

| Tables_in_almacen |

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

| articulo |

| fabricantes |

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

2 rows in set (0.02 sec)

mysql> DESCRIBE FABRICANTES;

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

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

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

| ID_FABRICANTE | int(11) | NO | PRI | NULL | |

| NOMBRE_FAB | varchar(30) | YES | | NULL | |


| DESCRIPCION | varchar(30) | YES | | NULL | |

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

3 rows in set (0.05 sec)

mysql> DESCRIBE ARTICULO;

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

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

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

| ID_ARTICULO | int(11) | NO | PRI | NULL | |

| ID_FABRICANTE | int(11) | YES | MUL | NULL | |

| NOMBRE | varchar(30) | NO | | NULL | |

| PRECIO | int(11) | NO | | NULL | |

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

4 rows in set (0.05 sec)

mysql>

Vous aimerez peut-être aussi