I always forget this piece, as MySQL unlike SQL Server doesn't have a convenient data import tool, but instead provides a flexible command line import feature.
To import CSV (for example) data into MySQL you need;
- A database container
- A table
Let's start with a new database;
create database myDataImportExample;
use myDataImportExample;
Now we need a table for the data;
create table myData (
ticker varchar(14),
tradeDate varchar(8),
openPrice decimal(17,4),
volume bigint
);
Then import the data that has the 4 columns of data;
load data infile '/home/user1/myData.csv'
INTO table myData
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
No comments:
Post a Comment