Home » SQL & PL/SQL » SQL & PL/SQL » How to change the table name?
How to change the table name? [message #38580] Sun, 28 April 2002 18:12 Go to next message
m.a
Messages: 2
Registered: April 2002
Junior Member
Hi,

I wanna know please how to change the table name after it created?
Thanks,
Re: How to change the table name? [message #38583 is a reply to message #38580] Mon, 29 April 2002 03:15 Go to previous message
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.
Previous Topic: Newbie Needs Help - How to Calc Average without Aggregate Function
Next Topic: Trigger won't update timestamp??!
Goto Forum:
  


Current Time: Thu Mar 28 07:35:14 CDT 2024