MySQL Forums
Forum List  »  General

script to import multiple csv file into multiple tables having same schema
Posted by: shailesh patil
Date: March 30, 2018 03:56AM

I have about 50 csv files and I need to import them into 50 different database tables. I tried many thing but just couldn't find a way.The file and table names are same.

LOAD DATA LOCAL INFILE 'C:\\ABC\\MySQL\\TableSchema\\xyz.csv'
INTO TABLE xyz
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;


Above code lets me load 1 file at a time but I want to automate for multiple files .I stored all table names in table fetched them in a cursor and tried to change file name and table name by concatenating string variables using cursor but it is not working. Can somebody have idea about this .

Options: ReplyQuote


Subject
Written By
Posted
script to import multiple csv file into multiple tables having same schema
March 30, 2018 03:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.