What is the syntax to rename a table or view in Oracle?
-
6@skaffman: lmgtfy.com/ is just the thing you need :) – OMG Ponies Sep 09 '09 at 20:27
5 Answers
ALTER TABLE mytable RENAME TO othertable
In Oracle 10g
also:
RENAME mytable TO othertable

- 413,100
- 91
- 616
- 614
-
1In oracle versions older than 10g, views can no longer be renamed. Drop/recreate is the only possible way to do this now. Check separate answer for an example. – Wouter Sep 08 '15 at 14:14
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)

- 59,135
- 14
- 106
- 158
-
1in 11g, the initial example you have there didn't work for me, but the second did... – rogerdpack Apr 24 '13 at 16:33
-
Note that RENAME still works in 11g and 12g - refer http://docs.oracle.com/database/121/SQLRF/statements_9020.htm#SQLRF01608 – Jeffrey Kemp Sep 09 '15 at 10:39
In order to rename a table in a different schema, try:
ALTER TABLE owner.mytable RENAME TO othertable;
The rename command (as in "rename mytable to othertable
") only supports renaming a table in the same schema.

- 3,932
- 1
- 17
- 12
One can rename indexes the same way:
alter index owner.index_name rename to new_name;

- 10,473
- 9
- 65
- 96

- 19
- 1
Past 10g the current answer no longer works for renaming views. The only method that still works is dropping and recreating the view. The best way I can think of to do this would be:
SELECT TEXT FROM ALL_VIEWS WHERE owner='some_schema' and VIEW_NAME='some_view';
Add this in front of the SQL returned
Create or replace view some_schema.new_view_name as ...
Drop the old view
Drop view some_schema.some_view;

- 1,829
- 3
- 28
- 34