TechView with Kamlesh khaliya

Resources for OCP, Oracle Interviews(kamleshkhaliya@gmail.com)

Tuesday 13 March 2012

Is it possible to re-name a view? How to re-name a view in oralce?


Yes. You can rename a view in oracle with rename statement as :
Rename old_name to new_name;

RENAME command works for tables, views, sequences and private synonyms, for your own schema only.

For renaming a table, trigger and index you can also use Alter command like :
Alter table old_name rename to New_name;
Alter trigger old_name rename to New_name;

But a view can't be renamed with Alter command even it's supporting Alter command for explicitly recompile a view that is invalid or to modify view constraints.

There is one more way to rename an object in oracle, that is drop the object and recreate it with a different name.
But it's different than the previous methods we discussed. If you drop and re-create an object, all privileges granted for that object are lost where as in re-name “Oracle Database automatically transfers grants on the old object to the new object and if the object is a table then also transfer integrity constraints and indexes“

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home