|
Move table (Prior 8i Versions)Let's discuss the various methods available to move a table from one tablespace to another or from one schema to another in Oracle versions prior to 8i. Let's have the table EMPLOYEE on PAYROLL_DATA tablespace owned by user PAY for discussion. Here are some scenarios, you may also combine the different methods discussed here. 1. Change owner of the tableTask: Move the table EMPLOYEE owned by PAY to the schema PAYROLL. Steps: 1. Take export of the table
2. It does not matter, if you drop or rename the old table or leave it there. Better to drop it to avoid confusion.
3. Import the table to PAYROLL.
4. Make sure the public synonym, if any exists, point to the right table. 2. Change the tablespace of the tableTask: Move the table EMP from tablespace PAYROLL_DATA to PAY_DATA. Method 1: 1. Take export of the table
2. Drop the table.
3. Revoke unlimited tablespace from user PAY.
4. Change tablespace quota assignments for user PAY.
5. Import the table to PAY.
6. Change back the default tablespace and quota assignments for PAY. Method 2: 1. Take export of the table
2. Drop the table.
3. Import the table with indexfile option to create the table and index create script.
4. Edit the employee.sql file to change the tablespace name and, if required, the storage parameters. 5. Do the import
Method 3: 1. Rename the original table.
2. Create the new table from a subquery of the old table. This method will not work if any of the column data type is LONG.
3. Apply the grants, constraints, triggers on employee_old table to the new employee table.
|