Page 1 of 1

Import data from excel to database

Posted: Wed Jul 08, 2009 9:12 pm
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?

Re: Import data from excel to database

Posted: Wed Jul 08, 2009 10:05 pm
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.

Re: Import data from excel to database

Posted: Wed Jul 08, 2009 11:17 pm
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?

Re: Import data from excel to database

Posted: Thu Jul 09, 2009 11:34 am
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).

Re: Import data from excel to database

Posted: Fri Jul 10, 2009 3:23 am
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!