Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Renaming a table in a database
Message
 
To
01/06/1999 09:05:54
Kenneth Downs
Secure Data Software, Inc.
New York, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00224160
Message ID:
00224879
Views:
13
>Gracefully? Probably not. But it is doable. The line of commands would be something like:
>
>OPEN DATABASE MyDataBase
>SET DATABASE TO MyDataBase
>REMOVE TABLE MyTable
>Rename MyTable.DBF TO MyNewName.DBF
>Rename MyTable.CDX To MyNewName.CDX
>Rename MyTable.FPT To MyNewName.FPT
>ADD TABLE MyNewName
>
>Of course you may now ask, "What happens to my captions, defaults, triggers, relations, etc?" They are lost.
>
>You could try another approach here as well, something like this:
>1. Open the database as a table
>2. Find the record of ObjectType = "Table" with your table's name and note its ID number.
>3. Select the records whose "ParentID" matches your table and put them off in a temporary table.
>4. Close the DBC and rename the table as described above.
>5. After adding the table back in, open the DBC as a table and find the record of OBjectType = "Table" with your table's new name. Note the new ID Number
>6. Delete all records in the DBC with ParentID = the new ID Number
>7. Append in the records from your temporary table, changing the ID Number at some point (preferably before you append).
>
>You could still run into errors if you have relations, as they will name tables explicitly.

See my response - there's not much to it, really. You can either move or rename a table (in, for example, Windows Explorer) and any associated files (CDX, FPT). Then you just need to do a VALI DATA RECO or attempt to open the table in the DBC, and you just need to point it to the right file, and the DBC will update itself...

Not totally graceful, but close :)
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.
Previous
Reply
Map
View

Click here to load this message in the networking platform