Rename Oracle Table or View

前端 未结 5 1086
情歌与酒
情歌与酒 2020-12-13 23:27

What is the syntax to rename a table or view in Oracle?

5条回答
  •  眼角桃花
    2020-12-14 00:01

    To rename a table you can use:

    RENAME mytable TO othertable;
    

    or

    ALTER TABLE mytable RENAME TO othertable;
    

    or, if owned by another schema:

    ALTER TABLE owner.mytable RENAME TO othertable;
    

    Interestingly, ALTER VIEW does not support renaming a view. You can, however:

    RENAME myview TO otherview;
    

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

    If the view is not in your schema, you can recompile the view with the new name and then drop the old view.

    (tested in Oracle 10g)

提交回复
热议问题