Jump to content


Photo

Loading data from a local infile


  • Please log in to reply
2 replies to this topic

#1 fredpickwick

fredpickwick
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 31 October 2003 - 06:56 PM

mysql> LOAD DATA LOCAL INFILE \"pet.txt\" INTO pet;

Could somebody please tell me where the data file \"pet.txt\" has to be for the above instruction to work?

#2 DylanBlitz

DylanBlitz
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationOC Baby!

Posted 31 October 2003 - 07:40 PM

mysql> LOAD DATA LOCAL INFILE \"pet.txt\" INTO pet;

with that I believe you have to have the pet.txt in the same directory the mysql program is running in. a better way to do it would be like

mysql> LOAD DATA LOCAL INFILE \"/path/to/file/pet.txt\" INTO pet;

and make sure the permissions are set so mysql can access it.

if your running on windows then I think the path needs to be something like

mysql> LOAD DATA LOCAL INFILE \"C:\\path\\to\\file\\pet.txt\" INTO pet;

hope that helps :)

#3 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 01 November 2003 - 05:23 AM

How have you stored the value sin the text files

meaning

How are the fields seprated and how are the records seprated.

If you have it as CSV comma seprated vlaues you can try this

LOAD DATA INFILE \'C:\\pet.txt\' INTO TABLE pet FIELDS TERMINATED BY \',\' LINES TERMINATED BY \'n\';

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users