I was just doing some R&D to find out whatz happenning when we are renaming a table name from X to Y.
The following are my observations
1. I got a table called numbers_1 which got 1900002 rows as shown below
SQL> show user;
USER is "DEMO"
SQL>select count(*) from numbers_1;
COUNT(*)
----------
1900002
2. Started a select query from numbers_1 as shown below
SQL>select * from numbers_1;
THis query is running...
I logged-in in another window as demo user Renamed the numbers_1 to numbers.
The select query is still running.
This is captured in the following video.
3. The Constraints, Indexes built on the original table are also reflected with the new table name.
This is as shown below Before and after Rename of EMP table:
SQL> select constraint_name,table_name from user_constraints;
CONSTRAINT_NAME TABLE_NAME
------------------------------ ------------------------------
FK_DEPTNO EMP
PK_DEPT DEPT
PK_EMP EMP
SQL> select index_name,table_name from user_indexes;
INDEX_NAME TABLE_NAME
------------------------------ ------------------------------
PK_DEPT DEPT
IDX_NUM1 NUMBERS_1
PK_EMP EMP
SQL> alter table emp rename to NEW_EMP;
Table altered.
SQL>select constraint_name,table_name from user_constraints;
CONSTRAINT_NAME TABLE_NAME
------------------------------ ------------------------------
FK_DEPTNO NEW_EMP
PK_DEPT DEPT
PK_EMP NEW_EMP
SQL> select index_name,table_name from user_indexes;
INDEX_NAME TABLE_NAME
------------------------------ ------------------------
PK_DEPT DEPT
IDX_NUM1 NUMBERS_1
PK_EMP NEW_EMP
Note: But the PL/SQL packages which has the references to the old table name becomes invalid after the Table rename.
Blog Archive
-
▼
2008
(9)
-
▼
July
(8)
- Monitoring DML ( Insert/Update/Delete) Operations ...
- Table Rename - What Happens to the Indexes,constra...
- Monitoring the Space Usage in TEMPORARY tablespace
- Resizing a temporary tablespace TEMP
- Monitoring the Oracle Database - "Processes" Initi...
- How to Enable / Disable Archive log Mode in 10g
- How to Increase the OC4J JVM heap size in Oracle A...
- How to Increase the JVMs for an OC4J Instance in R12
-
▼
July
(8)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment