There is a direct command to rename table.
The syntax is as follows
alter table
table_name
rename to
new_table_name;
Note: When the table is renamed the referenced object like PL/SQL, applications etc are not updated. Hence this may make those invalid. However the indexes, constraints etc are updated.
4 Comments:
i can rename several tables like this
alter table original rename to work;
alter tmp original rename to original;
alter table work rename to tmp;
but this is not atomic.
i want to rename all my tables in one line, how can i do this.
how can i create a procedure for the dbms_output.put_line package. i dont want to type the command dbms_output.put-line all the time instead of that i want to write a procedure and want to call when ever required
Create private procedure and call that within your program
e.g.
CREATE PACKAGE BODY xx AS
PROCEDURE log(p_string VARCHAR2)
IS
dbms_output.put_line(p_string);
END;
...
...
-- main code
log('print message');
...
...
END xx;
Hope this is helpful.
Suresh
Wow. I have always renamed the tables one by one and have not used any procedure to do this task atomic. As you have mentioned the procedure also I will implement this but what to do to make the relevant changes in other corresponding objects like PL/SQL & applications that make use of these tables.
Post a Comment