MySQL Forums
Forum List  »  MySQL Workbench

Script to change foreign key of tables?
Posted by: Carlos Quiros
Date: August 01, 2011 08:23AM

Hi,

I need to make an script to change the referenced table of a table. Something that would look like

String previousReferencedTable;
String newReferencedTable;

for (int a = 1; a <= totalTablesInModel; a++) //Browse through the tables
{
int totalkeys = tables[a].totalForeignKeys //For each table get the total keys
for (int b= 1; b <= totalkeys; b++) //Browse through the keys in a table
{
if (table[a].ForeignKeys.ReferencedTable == previousReferencedTable) //Check if the current Referenced table is the old table
{
table[a].ForeignKeys.ReferencedTable = newReferencedTable //Replace the current referenced table with the new table
}
}
}

Thanks in advance!
Carlos

Options: ReplyQuote


Subject
Views
Written By
Posted
Script to change foreign key of tables?
2079
August 01, 2011 08:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.