To dump specific columns of a given file in mysql database.
Hello everyone,
I've been in a problem to dump columns of my choice into a mysql database from a given text file that looks like this. Quote:
|
It may help us to know the desc of the table, so
mysql > Code:
desc dbname.table; |
I've created a table called Station, which has three attributes namely stationID, X_coord, Y_coord. And the input file, there are around 16 attributes delimited by tabs, in which columns 3,4,and 5 match the attributes of the station table. The problem is to dump only those columns to the database and ignore the others. Thanks for your time
|
Quote:
Basic MySQL select, easily found if you tried to look: https://dev.mysql.com/doc/refman/5.7/en/select.html Since you apparently want to be fed the answer: Code:
SELECT field1,field2,field3 FROM table INTO OUTFILE '/some/file.name' FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'; However, if you want to LOAD data from a text file into a database, then strip off the first column of data, which will leave you a text file with just the three columns you want. You can use awk for that. Then use the MySQL "load data" command (again, a SMALL bit of research would tell you this): https://dev.mysql.com/doc/refman/5.7...ng-tables.html |
All times are GMT -5. The time now is 12:15 AM. |