mysql insert using bash script
hi ,
THere is one csv file in that there are 100 lines. i have to insert each line into mysql table? plz give me the bash script!! i am unble to solve.. eg 1.csv 1,2,3,4,5 1,3,4,6,8 there is mysql table . i have to insert these values into table!! plz help |
Hi
Take a look at: http://dev.mysql.com/doc/refman/5.0/en/load-data.html You don't write the command in bash, but in mysql. So something like: mysql databasename LOAD DATA INFILE '1.csv' INTO TABLE TheTable FIELDS TERMINATED BY ','; |
hi , its very useful data but..
i have table called rss in that there are attributes one , two ,three ,four,five desc rss -> ; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | one | varchar(255) | YES | | NULL | | | two | varchar(255) | YES | | NULL | | | three | varchar(255) | YES | | NULL | | | four | varchar(255) | YES | | NULL | | | five | varchar(255) | YES | | NULL | | | six | varchar(255) | YES | | NULL | | +-------+--------------+------+-----+---------+-------+ 6 rows in set (0.00 sec) where as my rss fields are 1,2,3,4,5 now i want to insert 1 in one,2 in two........ plz help |
Quote from the manual page:
Quote:
LOAD DATA INFILE 'file.txt' INTO TABLE rss (one two, three, four, five, @dummy); |
All times are GMT -5. The time now is 04:08 PM. |