We will show you how to export Excel data to MySQL db.
The steps are:
1) saved the excel data to csv format, such as below
BK001,Introduction to science,976,85.0
BK002,Human Anatomy,985,200.0
BK003,Concepts in Health,765,100.5
2) create a db table that matches the csv format
mysql> create table book_info
-> (book_id varchar(20), book_name varchar(40), isbn_no int(11), book_price, int(10));
3) run the mysql command
mysql> load data infile 'c:\\Book1.csv' into table book_info fields terminated by ',' lines terminated by '\n';
Query OK, 3 rows affected (0.07 sec)
Records: 3 Deleted: 0 Skipped: 0 Warnings: 0
After that, the db contains the Excel data, To verify, issue the command:
mysql> select * from book_info;
+---------+-------------------------+---------+------------+
| book_id | book_name | isbn_no | book_price |
+---------+-------------------------+---------+------------+
| BK001 | Introduction to science | 976 | 85 |
| BK002 | Human Anatomy | 985 | 200 |
| BK003 | Concepts in Health | 765 | 101 |
+---------+-------------------------+---------+------------+
3 rows in set (0.00 sec)
No comments:
Post a Comment