oracle - how to copy partitioned table to a new schema on new tablespace - oracle

I created a datapump export (Oracle 11g) from SCHEMA A on a partitioned table (tablespace TEST``) usingTABLE=MYPARTTBL:MYPART`.
I created a new schema SCHEMA B and imported the dump of SCHEMA A's partitioned table with success, but it created the table using the same tablespace TEST.
What I need to do is import the partitioned table to a different tablespace TEST_NEW.
What's a good way to do this? Considering now, that I have a copy of SCHEMA A's partitioned table in SCHEMA B.
Here's my export parfile parameters:
DIRECTORY=DW_PUMP
TABLES=MRA.FACT_USE:P_20111009
DUMPFILE=MRA.TBLPART-20111209.dmp
LOGFILE=MRA.TBLPART-20111209.log

Use the REMAP_TABLESPACE parameter when importing:
REMAP_TABLESPACE=TEST:TEST_NEW

Related

Dynamic Partition on external hive table

Is there a way to dynamically partition an external Hive table? I referred to posts which mentioned to follow below steps -
Create an external non-partitioned table
Create an external partitioned table
Use insert into table command to insert the data from non-partitioned to partitioned table
Problem with the above solution is that I need to always use the insert command if my base (non-partitioned) table is modified (addition/deletion of parquet files).
I am seeking for a solution where I need not do any insert command and my partitioned table should be updated as and how my non-partitioned table is changed.

Generate Alter statements of partition of all existing tables from Oracle views in 12c

I want to generate dynamically the below alter code(the below one is an eg, it will differ table to table) for all the partitioned tables in 12c DB.
Some tables may be partitioned on RANGE, LIST etc.
The column name, partition type will also change as per the table.
ALTER TABLE EMP
MODIFY PARTITION BY RANGE (START_DATE)
( PARTITION P1 VALUES LESS THAN (date'2021-1-1') ) ONLINE;
I have already created tables without partition in another db and now want to partition those tables which were partitioned in the source db. So want a simple script which can create code to partition the tables in the target db. Note - all tables have different partition and my goal is to make them sync with source. Only data differs in both the DBs.

Export bytea data from Postgres and Import it as blob to Oracle DB

I have a table with bytea column type I need to export this data and import it to similar table in Oracle Db (as blob because there is no bytea type)
You could use oraclle_fdw, define the empty Oracle table as foreign table in PostgreSQL and move the data with
INSERT INTO foreigntab SELECT * FROM localtab;
The performance won't be top notch, but it is simple.

Steps to restore one table from impdp in oracle 10g

I need to import only one table from a full backup (expdp) to a newly create table on the same database.
So can i import the table directly with a new name? or i have to create a new table first with the same parameters then import?
impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expschema.dmp TABLES=hr.employees REMAP_TABLE=hr.employees:emps
Another question will remap_table effect my already exist employees table? or it will only create a new table called emps and import the data of employees from the dump to it?
...................... Update ......................
I found that there is no remap_table in oracle 10g so can i use this method:
create user johny identified by 1234;
grant create session to johny;
impdp system/****** DIRECTORY=dpump_dir1 DUMPFILE=expschema.dmp LOGFILE= tb_imp.log TABLES='HR.employees' REMAP_SCHEMA=HR: johny;
We need the table temporarily only so i can drop johny later. also the above method will not effect the original employees table in the hr schema , right?
Oracle will import the table employees from your dump file and remame it to emps, if an employees table exists it will not be affeted, if the emps table already exists it will not do anything.
You can change the behavior when a table exists by using the table_exists_action parameter either specifiying:
TRUNCATE => truncate the table if exists and import data from the
dump
REPLACE => will first replace the table with the definition
from the dump and then import the data
APPEND => will append the
data to the table leaving the existing data in.

Oracle Database: How can I alter a partitioned table to a new table space for not only the partitions but also the table itself?

How can I alter a partitioned table (in Oracle 10g Database) to a new table space for not only the partitions but also the table itself? Which I mean is, I can do following without issues,
--sql
alter table abc move partition abc01 tablespace new_tablespace;
alter table abc move partition abc02 tablespace new_tablespace;
alter table abc move partition abc03 tablespace new_tablespace;
but somehow the table's definition is still associating with the old table space, and and I have moved all tables data off the old table space. If I query the dba_segment for the old table space, there is nothing there. My question is, may I drop the old table space, even no data in the data files in the old table space, but somehow those partitioned tables definitions still associating with the old table space?
Each partition must be moved, as you've discovered. If you want new partitions to be created in a different tablespace without specifying that new tablespace, you'd have to use the following:
alter table abc modify default attributes tablespace new_tablespace;

Resources