Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 345868230 1646198120 1531283146 Keyword_1531283146 1.55 252910000
- 745345566 1646198120 1539847239 another_1531276364 2.75 987831000
- ...
- LOAD DATA INFILE '/tmp/mydata.txt' INTO TABLE PerformanceReport;
- CREATE TABLE foo(myid INT, mymessage VARCHAR(255), mydecimal DECIMAL(8,4));
- 1 Heart disease kills 1.2
- 2 one out of every two 2.3
- 3 people in America. 4.5
- LOAD DATA LOCAL INFILE '/tmp/foo.txt'
- INTO TABLE foo COLUMNS TERMINATED BY 't';
- Query OK, 3 rows affected (0.00 sec)
- Records: 3 Deleted: 0 Skipped: 0 Warnings: 0
- mysql> select * from foo;
- +------+----------------------+-----------+
- | myid | mymessage | mydecimal |
- +------+----------------------+-----------+
- | 1 | Heart disease kills | 1.2000 |
- | 2 | one out of every two | 2.3000 |
- | 3 | people in America. | 4.5000 |
- +------+----------------------+-----------+
- 3 rows in set (0.00 sec)
- LOAD DATA LOCAL INFILE '/tmp/foo.txt' INTO TABLE foo
- FIELDS TERMINATED BY 't' LINES TERMINATED BY 'n'
- (@col1,@col2,@col3) set myid=@col1,mydecimal=@col3;
- mysql> select * from foo;
- +------+-----------+-----------+
- | myid | mymessage | mydecimal |
- +------+-----------+-----------+
- | 1 | NULL | 1.2000 |
- | 2 | NULL | 2.3000 |
- | 3 | NULL | 4.5000 |
- +------+-----------+-----------+
- 3 rows in set (0.00 sec)
- LOAD DATA LOCAL
- INFILE '/tmp/mydata.txt' INTO TABLE PerformanceReport
- COLUMNS TERMINATED BY 't' ## This should be your delimiter
- OPTIONALLY ENCLOSED BY '"'; ## ...and if text is enclosed, specify here
- LOAD DATA INFILE '/tmp/test.txt'
- INTO TABLE test
- FIELDS TERMINATED BY ','
- LINES STARTING BY 'xxx';
- xxx"abc",1
- something xxx"def",2
- "ghi",3
- LOAD DATA INFILE 'data.txt'
- INTO TABLE tbl_name
- FIELDS TERMINATED BY ','
- ENCLOSED BY '"'
- LINES TERMINATED BY 'rn'
- mysqlimport -u root -ptmppassword --local test employee.txt
- test.employee: Records: 3 Deleted: 0 Skipped: 0 Warnings: 0
- local-infile=1
- mysql --local-infile -uroot -pyourpwd yourdbname
- LOAD DATA LOCAL INFILE '/softwares/data/data.csv' INTO TABLE tableName;
Add Comment
Please, Sign In to add comment