Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add a field between others by code
Message
From
11/04/2009 11:29:47
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01394334
Message ID:
01394336
Views:
66
This message has been marked as a message which has helped to the initial question of the thread.
>I want to write an update program to update a table one of my products and i need to add a field between field 4 and 5,How?
>i write this code but it add that field at the bottom of fields :
>
>Alter Table contacts Add cdate c(10)
>
Normally the order of fields should not be that important. You can have the field at any place.

On the other hand, to update table structures, I have used this general strategy, which covers practically most cases:

Do the changes manually (modify structure, etc.), in an empty copy of the database. That is, all tables have zero records.

Have a program that combines the empty structure with the production data. Basically:
  • Make a copy of the empty structure to a temporary directory.
  • Do an APPEND FROM for each table (from the production data, to the temporary directory).
  • (Note that for a parent-child relation, the parent has to be copied first.)
  • Make a backup of the production data.
  • Copy the temporary directory over the production data.

    If there are absolutely no changes in the structure for a certain table, that table (plus index, plus memo) can be copied as files, which is much faster. But detecting changes in structure is fairly complicated - there are several things you have to check.

    All this is more complicated than what you are asking for, but it doesn't require a special update program for every individual change, so it is much simpler in the long-term.
    Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
  • Previous
    Reply
    Map
    View

    Click here to load this message in the networking platform