| Line: 1 to 1 | ||||||||
|---|---|---|---|---|---|---|---|---|
| Added: | ||||||||
| > > |
So, you want to convert some FoxPro? tables to PostgreSQL?, huh? Here's how you do it:
dumprecspg will generate the commands necessary to create near-exact replicas of your tables. Its output looks something like:
begin; drop table invoice; create table invoice (div char(3), shipid integer, invid integer, xrscust char(10), bil2code char(10), typeofinv char(10), typeinv char(6), pay2addrid integer, bil2addrid integer, xrsweek char(5), invnum char(19), refnum char(25), orig_supp char(2), new_corr char(1), del_sit char(1), invamt text, invdte date, bildttm timestamp, bil char(3), chkdttm timestamp, chk char(3), cr8dttm timestamp, meth char(3), misc text, del boolean, paiddttm timestamp, bilext char(15), chkext char(15)); \copy invoice from stdin ... ... ... \. commit;Note that the entire process is wrapped inside a transaction so that other clients will have access to the old data until the transaction is completed. Indices are automatically created if you specify the columns (or expressions!) you want indexed on the command line. For example, dumprecspg foo.dbf rowid "substr(textfield,1,4)" pricewill create three indices on the new foo table: one each for the rowid and price columns, and one for the substr() expression. It tries to give each index a reasonable name, but YourMileageMayVary? CaveatsIt doesn't check that a table exists before dropping it. This causes an error in PostgreSQL? if the table doesn't exist. Workaround: create a trivial table with the same name, ala:CREATE TABLE invoice (foo integer);If a table has memo fields, they'll be stored in tablename.fpt. Be sure that the case matches between that table and your main .dbf table! For example, if your data table is named invoice.dbf, be sure your memo table is named invoice.fpt, not Invoice.FPT or iNvOiCe.FpT! Windows doesn't care about case. Unix isn't so liberal.
-- KirkStrauser - 20 Oct 2005
| |||||||