Jump to content

loading a txt file into mysql to create a database


CherryLips

Recommended Posts

Hello,

 

I am trying to load a txt file into mysql -uroot to create a database with all the tables and everything is prewritten. Here is what I thought I was supposed to write (but it's not working):

 

mysql -uroot < skel_mysql.txt

 

the skel_mysql.txt file is located in xampp/mysql/bin and this is a copy of the text in the file.

 

CREATE DATABASE skel;
USE skel;

CREATE TABLE customers (
ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
LAST CHAR(20) NOT NULL,
FIRST CHAR(20) NOT NULL,
PHONE CHAR(20) NOT NULL,
SESSID CHAR(32) NOT NULL );

CREATE TABLE products (
SKU INT NOT NULL PRIMARY KEY,
NAME CHAR(20) NOT NULL,
DESCR VARCHAR(40) NOT NULL,
PRICE DECIMAL(9,2) NOT NULL,
IMAGE VARCHAR(20) NOT NULL );

INSERT INTO products VALUES(1121,'Small Lab Coat','White Lab Coat Adult Small',15.75,'labcoat.png'),
(1122,'Medium Lab Coat','White Lab Coat Adult Medium',15.75,'labcoat.png'),
(1123,'Large Lab Coat','White Lab Coat Adult Large',16.75,'labcoat.png'),
(1124,'Beaker Kit','Set of 5 different beakers',22.05,'beakers.png'),
(1125,'Petri Dishes','Set of three',9.99,'petri.png'),
(1126,'Safety Glasses','Women's Safety Glasses',15.75,'wmglass.png'),
(1127,'Mens Safety Glasses','Men's Safety Glasses',15.75,'mglass.png'),
(1128,'Kids Safety Glasses','Kid's Safety Glasses',15.75, 'kglass.png'), ;


CREATE TABLE cart (
ID CHAR(32) NOT NULL,
DATE DATETIME NOT NULL,
QTY INT NOT NULL,
SKU INT NOT NULL );

 

Side note: I thought there was an error in my database so I dropped it and rewrote the code in a txt file and now I dont want to rewrite everything in the cmd prompt. This is for a simple shopping cart assignment Im doing for a PHP class.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.