How to Remove Table from Persistent Relation with ProgramLast reviewed: April 30, 1996Article ID: Q130352 |
The information in this article applies to:
SUMMARYThis article shows three methods you can use to remove a table from a Persistent Relation.
MORE INFORMATIONUse the following code to create an example database (DBC) with two tables in a Persistent Relation:
CREATE DATABASE pr_dbc CREATE TABLE pr_Paren (cid c(3) PRIMARY KEY, cfld2 c(3)) CREATE TABLE pr_Child (cid c(3) REFERENCES pr_Paren TAG cid, ; cfld2 c(3), cfld3 c(3)) MODIFY DATABASE && To view the persistant relationship Method One - RiskyDrop or remove the PRIMARY KEY from the parent table as in this example:
ALTER TABLE pr_Paren DROP PRIMARY KEYThis command successfully removes the parent table from any and all Persistent Relations in which the table is participating. It also removes the PRIMARY Key index tag from the table. This is not a "safe" method to use because of the scope of its effect.
Method Two - SaferDelete the tag in the child table that is part of the Persistent Relation as in this example:
USE pr_Child DELETE TAG cidThis method breaks the Persistent Relation, but it also deletes the tag in the pr_Child table.
Method Three - Best MethodUse the following command:
ALTER TABLE-SQL's DROP FOREIGN KEY TAG <Tagname> [SAVE]This command successfully removes the child table from the Persistent Relation and the [SAVE] clause preserves the child table's index tag. Here is an example using the example database:
ALTER TABLE pr_Child DROP FOREIGN KEY TAG cid SAVEIf the SAVE clause is not used, the cid tag is deleted from the pr_Child table. Methods two and three are safer than method one because they have a relatively narrower scope of effect with fewer global changes. Removing the primary key, as method one does, could destroy one or more other persistant relations, which you may not want to do.
|
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |