Question

I have a parent table (ParentId) and a child (ParentId,ChildId) table. ParentId in the parent table is defined as VARCHAR2 ( 25 characters ) and so is ParentId in the child table. I want to change the data type to VARCHAR2 ( 50 characters ) . Can I do it in such a way that this change is cascaded to the Child table ?

Cheers !

Était-ce utile?

La solution

No. There is no way to cascade the changes. (Well, there might be some obscure way if you had defined your columns based on the same user-defined type but that would undoubtedly create more issues than it would solve). You'd need to issue one ALTER for the parent and one for the child table.

If you have a more complicated schema where you're trying to trace changes from a parent table through many child and grandchild tables, you could use the data dictionary to walk the hierarchy. Here is one query to return the table hierarchy based on one of Frank Kulash's OTN Forums posts. If the column is named the same in every table, you can do something even easier and just query dba_tab_columns for all the columns with that name and a data_length of 25 rather than 50.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top