Ein Tabelle in Oracle umbenennen - Unterschied RENAME und ALTER TABLE - ORA-01765 und ORA-14047

Problem: „ORA-01765: specifying owner's name of the table is not allowed“ - „ORA-14047: ALTER TABLE|INDEX RENAME may not be combined with other operations“

Welche Möglichkeiten bestehen um eine Tabelle umzubennen?

Aber was ist der Unterschied zwischen den beiden Möglichkeiten?

RENAME xxxxx to yyyy

Aus der Dokumentation:

.. Prerequisites

The object must be in your own schema.
..

D.h. ein Aufruf von:

CONNECT system
 
RENAME scott.emp TO scott.emp_orig;
 
 
ORA-01765: specifying owner s name OF the TABLE IS NOT allowed
 
 
-- Richiger Aufruf:
 
CONNECT scott
 
RENAME semp TO  emp_orig;

Eine Verwendung als NICHT Schema Owner führt zu einer Exception „ORA-01765: specifying owner's name of the table is not allowed“!

ALTER TABLE schema.xxxx RENAME TO yyyyyy

Hier kann nun das Schema angeben werden, es ist aber darauf zu achten, dass nur das umzubenennende Objekte inklusive Schema Namen angegeben wird!

D.h. ein Aufruf von:

-- Falsch
 
ALTER TABLE scott.emp  RENAME TO scott.emp_orig;
 
 
ORA-14047: ALTER TABLE|INDEX RENAME may NOT be combined WITH other operations
 
-- Richiger Aufruf:
 
 
ALTER TABLE scott.emp  RENAME TO emp_orig;

Quellen