|
Re: How to change the table name? [message #38583 is a reply to message #38580] |
Mon, 29 April 2002 03:15 |
Saga
Messages: 51 Registered: April 2002
|
Member |
|
|
Try this one out
-- Original table: EMP
-- Backup of table: EMP_X
-- Lock original table before rename
LOCK TABLE EMP IN EXCLUSIVE MODE ;
-- Make backup copy of original table
RENAME EMP TO EMP_X ;
-- Remove all other NAMED Table Constraints because
-- they will cause errors when re-creating the table
-- Recreate original table
CREATE TABLE EMP (
ENAME VARCHAR2 (25) NOT NULL,
EMPNO VARCHAR2 (5) NOT NULL,
SAL NUMBER (30) NOT NULL,
MGR VARCHAR2 (5) NOT NULL )
TABLESPACE USER PCTFREE 10
STORAGE(INITIAL 40K NEXT 40K PCTINCREASE 50 ) ;
-- Copy the data from the renamed table
INSERT INTO EMP (
ENAME, EMPNO, SAL, MGR )
SELECT ENAME, EMPNO, SAL, MGR
FROM EMP_X ;
COMMIT ;
Hope this example helps.
|
|
|