Import data from excel to database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
rei27
Forum Commoner
Posts: 27
Joined: Thu Apr 30, 2009 4:17 am

Import data from excel to database

Post by rei27 »

Is it impossible to import excel data to database's table? I know that it can be done by using MySQL command LOAD DATA INFILE 'path/file.txt' INTO TABLE your_table; , but how the data match with the table field? Is it necessary to declare it first?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Import data from excel to database

Post by califdon »

rei27 wrote:Is it impossible to import excel data to database's table? I know that it can be done by using MySQL command LOAD DATA INFILE 'path/file.txt' INTO TABLE your_table; , but how the data match with the table field? Is it necessary to declare it first?
It is definitely possible. You have the correct command. And you're correct, you have to know what data is in the spreadsheet and insure that you have an existing table with the appropriate fields. Even then, there are often difficulties if the spreadsheet contains formulas or headers, etc.
rei27
Forum Commoner
Posts: 27
Joined: Thu Apr 30, 2009 4:17 am

Re: Import data from excel to database

Post by rei27 »

califdon wrote:
rei27 wrote:Is it impossible to import excel data to database's table? I know that it can be done by using MySQL command LOAD DATA INFILE 'path/file.txt' INTO TABLE your_table; , but how the data match with the table field? Is it necessary to declare it first?
It is definitely possible. You have the correct command. And you're correct, you have to know what data is in the spreadsheet and insure that you have an existing table with the appropriate fields. Even then, there are often difficulties if the spreadsheet contains formulas or headers, etc.

That's means i must create the same table and fields for both excel and database. And the make sure the position for excel is exactly same with my database?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Import data from excel to database

Post by califdon »

rei27 wrote:That's means i must create the same table and fields for both excel and database. And the make sure the position for excel is exactly same with my database?
Yes, if you want to import it into an existing table. Of course, you can import into a new table and let Access make its own decisions about what data type each field will be, etc., as well as the field names (unless there is a header row in the spreadsheet with column names).
rei27
Forum Commoner
Posts: 27
Joined: Thu Apr 30, 2009 4:17 am

Re: Import data from excel to database

Post by rei27 »

califdon wrote:
rei27 wrote:That's means i must create the same table and fields for both excel and database. And the make sure the position for excel is exactly same with my database?
Yes, if you want to import it into an existing table. Of course, you can import into a new table and let Access make its own decisions about what data type each field will be, etc., as well as the field names (unless there is a header row in the spreadsheet with column names).

Thanks a lot! I will try it!
Post Reply