Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Renaming a table in a database
Message
From
28/05/1999 18:35:50
 
 
To
28/05/1999 17:59:26
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00224160
Message ID:
00224179
Views:
17
>>>>>I'm trying to rename a table in a database. The RENAME TABLE command only modifies the alias in the database, but does not rename the file(s) on disk.
>>>>>
>>>>>The RENAME command does not work, and in fact creates an error.
>>>>>
>>>>>Does anyone know how to do this gracefully?
>>>>>
>>>>>Thanks.
>>>>>
>>>>>Bob Bartel
>>>>>MarketWare
>>>>
>>>>Bob,
>>>>
>>>>I'm not quit sure about whow rename works, but you may try a statement like
>>>>
>>>>select * from mytable into DATABASE mydatabase NAME mynewtable and then delete the old one. Have a look a select sql in the help file.
>>>
>>>That's why I was asking for a "graceful" way of doing it. My concern is that if the table is large...I will run out of space on the disk to do what it is that I need to do...
>>>
>>>Thank you for your suggestion...
>>
>>Aha ...
>>If on the disk is barely enough space for the copy of one of your tables then you will experience a lot of other problems with your application and OS :-), let me think about another solution.
>
>I'm writing a commercial application, I do not know from one system to the next if I have enough space, etc., but I try to plan ahead, and make the process as effecient as possible. But, it sounds like there is a problem with renaming tables in VFP 6.0 that reside in a database. That sort of confirms my suspicion.

Bob,

I haven't found a better solution, only more info. The Rename command will rename only the LongTableName (= alias) from the dbc, update the name in the relations and for the indexes but NOT in the RI-Code (you have to regenerate it) or in any of your forms and methods !

Yeah, you're right that you have to be carefull in an unknown environment. My practice before any file operations is first to check for space ...

Possible solution: use the rename command to have the relations and indexes updated correctly, and write some code to rename the physical file and update the entries in the dbc (it's only a normal table), but you will still have the problem with ri-code and references from your forms and reports.
Vlad-Georg
Previous
Reply
Map
View

Click here to load this message in the networking platform