MySQL Forums
Forum List  »  Other Migration

Re: here is a way! Conversion between FoxPro .DBF and MySql Database
Posted by: Mukesh Arora
Date: November 02, 2009 12:40AM

Here is a simple way to copy foxpro structure into mysql table.

But this method is only for simple dbf files and not copy the records. It creates only table in mysql with same structure.

Assume you have database file dept.dbf with following fields

Field Field Name Type Width Dec Index Collate
1 DEPT Character 40
2 AMOUNT Numeric 8
3 BGT_HEAD Character 6
4 BGT_PAGE Numeric 3

Copy structure of your database in a text file like this

USE dept
list stru to abc

It will make abc.txt in same folder like this

1. Structure for database: E:\SP\DEPT.DBF
2. Number of data records: 82
3. Date of last update : 08/28/09
4. Code Page : 437
5. Field Field Name Type Width Dec Index Collate
6. 1 DEPT Character 40
7. 2 AMOUNT Numeric 8
8. 3 BGT_HEAD Character 6
9. 4 BGT_PAGE Numeric 3
10. ** Total ** 58


Now delete line number 1,2,3,4,5 & 6 then it will like

6. 1 DEPT Character 40
7. 2 AMOUNT Numeric 8
8. 3 BGT_HEAD Character 6
9. 4 BGT_PAGE Numeric 3

Now modify it in this way

Step1 - delete unwanted entries

DEPT Character 40
AMOUNT Numeric 8
BGT_HEAD Character 6
BGT_PAGE Numeric 3

Step2 - Add follwing entries

DEPT Character (40),
AMOUNT Numeric (8),
BGT_HEAD Character (6),
BGT_PAGE Numeric (3)

Step3 - replace all type in NOTEPAD
character->char
numeric->integer

DEPT Char (40),
AMOUNT Integer (8),
BGT_HEAD Char (6),
BGT_PAGE Integer (3)


Step4 - Add follwing entries
create table table-name ( ... );

create table dept (
DEPT Char (40),
AMOUNT Integer (8),
BGT_HEAD Char (6),
BGT_PAGE Integer (3)
);

Step5 - Now copy the above statement with
Ctrl+C

Step6 - Open the mysql prompt
Open the database

Now only use paste statement with keys Ctrl+V


Step - It will certainly create your table
check it through

show tables;
desc dept;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: here is a way! Conversion between FoxPro .DBF and MySql Database
9353
November 02, 2009 12:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.