Click to See Complete Forum and Search --> : Referencing an outside file through SQL


RPG Junkie
10-16-2007, 01:24 AM
Ok guys, I got a problem using MySQL to reference an outside file through an SQL script...I get an error saying that it cannot find the files themselves. The idea of this script is to point to other files that are in another directory and to use them as population scripts for the tables...

Here is the script I have. Yes it is one I downloaded and I'm using as an example so I can get more familiar with MySQL and phpMyAdmin and PHP...

So yeah, I don't see the problem...and I'm not getting much luck with teh almighty Google...

LOAD DATA LOCAL INFILE '.\\datafiles\\customers.txt' INTO TABLE Customers
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

SHOW WARNINGS LIMIT 10;

LOAD DATA LOCAL INFILE '.\\datafiles\\employees.txt' INTO TABLE Employees
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

SHOW WARNINGS LIMIT 10;

LOAD DATA LOCAL INFILE '.\\datafiles\\offices.txt' INTO TABLE Offices
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

SHOW WARNINGS LIMIT 10;

LOAD DATA LOCAL INFILE '.\\datafiles\\orderdetails.txt' INTO TABLE OrderDetails
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

SHOW WARNINGS LIMIT 10;

LOAD DATA LOCAL INFILE '.\\datafiles\\orders.txt' INTO TABLE Orders
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

SHOW WARNINGS LIMIT 10;

LOAD DATA LOCAL INFILE '.\\datafiles\\payments.txt' INTO TABLE Payments
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

SHOW WARNINGS LIMIT 10;

LOAD DATA LOCAL INFILE '.\\datafiles\\products.txt' INTO TABLE Products
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

SHOW WARNINGS LIMIT 10;

LOAD DATA LOCAL INFILE '.\\datafiles\\ProductLines.txt' INTO TABLE ProductLines
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
(productLine , textDescription);

SHOW WARNINGS LIMIT 10;