Tablerename
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Tablerename

on

  • 271 views

oracle foreign key primary key constraints performance tuning MTS IOT 9i block size backup rman corrupted column drop rename recovery controlfile backup clone architecture database archives export ...

oracle foreign key primary key constraints performance tuning MTS IOT 9i block size backup rman corrupted column drop rename recovery controlfile backup clone architecture database archives export dump dmp duplicate rows extents segments fragmentation hot cold blobs migration tablespace locally managed redo undo new features rollback ora-1555 shrink free space user password link TNS tnsnames.ora listener java shutdown sequence

Statistics

Views

Total Views
271
Views on SlideShare
271
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Tablerename Document Transcript

  • 1. Renaming a Table Administration TipsRenaming a TableThe basic command to do this is:ALTER TABLE SCHEMA.TABLE_NAME RENAME TO SCHEMA.NEW_TABLE_NAME;That command is guaranteed to work only in Oracle 8i and 9i -youll have to experiment tosee if it works on 8.0 or earlier versions.Issuing this command does not invalidate any indexes, constraints or permissions grantedon the original table.For example, if Fred has been granted select privileges on the EMP table, and the EMPtable is then renamed to be EMPLOYEES, Fred will now be able to select from EMPLOYEESwithout further grants being needed.Whilst indexes and constraints are all still valid and useable after a table is renamed, theyretain their original names. For example, if you created a constraint called EMP_ID_PK, itwill still be called that, even though it is now a constraint on the EMPLOYEES table.Similarly, an index called EMP_PK retains that name, regardless of the fact that the tableit is an index of has changed its name.You might therefore want to issue the command:ALTER INDEX SCOTT.EMP_PK RENAME TO SCOTT.EMPLOYEES_PK;However, there is no rename command for constraints, and hence they must retain theiroriginal names, unless you drop them and re-create them.Finally, renaming a table means performing DDL on a table -and performing DDL to anytable renders all procedures, packages and triggers that reference the table invalid. Youcan check that by looking at the STATUS column of the DBA_OBJECTS view. All invalidpackages, procedures and triggers are automatically recompiled the first time they arecalled after their invalidation (subject to some provisos), but you can also manuallyrecompile them if you wish: ALTER TRIGGER BLAH COMPILE;, for example.Incidentally, if you query DBA_TRIGGERS (as an example), you can see the code making upa particular trigger (in the TRIGGER_BODY column) -and youll discover that what was oncetyped in as create trigger blah before update on emp automatically gets re-jigged byOracle to read ...update on employees. The rename command therefore even re-writesyour code for you, which is nice!Copyright © Howard Rogers 2001 10/17/2001 Page 1 of 1