{"id":3460,"date":"2025-05-20T10:44:06","date_gmt":"2025-05-20T10:44:06","guid":{"rendered":"https:\/\/w3buddy.com\/?p=3460"},"modified":"2026-01-15T12:44:21","modified_gmt":"2026-01-15T07:14:21","slug":"how-to-perform-tablespace-level-export-import-within-the-same-oracle-database","status":"publish","type":"post","link":"https:\/\/w3buddy.com\/blog\/how-to-perform-tablespace-level-export-import-within-the-same-oracle-database\/","title":{"rendered":"How to Perform Tablespace-Level Export\/Import Within the Same Oracle Database"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Migrating a tablespace within the same Oracle DB instance can be useful for backup testing, development scenarios, or cloning environments. This step-by-step guide covers creating a dedicated tablespace, user setup, object creation, export\/import operations, and verification.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\uddf1 <strong>PART 1: Setup \u2013 Tablespace and User Creation<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd0d Check Existing Tablespaces and Datafiles<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT tablespace_name, file_name FROM dba_data_files;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2795 Create a New Tablespace<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE TABLESPACE galaxy <br>DATAFILE '\/u02\/oradata\/ORCL\/galaxy01.dbf' SIZE 100M <br>AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 Verify the Tablespace<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT tablespace_name <br>FROM dba_tablespaces <br>WHERE tablespace_name = 'GALAXY';<br><br>SELECT tablespace_name, SUM(bytes)\/1024\/1024 AS size_mb <br>FROM dba_data_files <br>WHERE tablespace_name = 'GALAXY' <br>GROUP BY tablespace_name;<br><br>SELECT file_name <br>FROM dba_data_files <br>WHERE tablespace_name = 'GALAXY';<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udc64 Create User with Default Tablespace<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE USER dev_user IDENTIFIED BY \"P@ssw0rd\" <br>DEFAULT TABLESPACE galaxy <br>QUOTA UNLIMITED ON galaxy;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd10 Grant Necessary Privileges<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">GRANT CONNECT, RESOURCE, CREATE SESSION, CREATE TABLE,CREATE VIEW, CREATE PROCEDURE, CREATE TRIGGER,CREATE SEQUENCE, CREATE SYNONYM TO dev_user;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccb Check User Details<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT username, default_tablespace <br>FROM dba_users <br>WHERE username = 'DEV_USER';<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce6 Check User Tablespace Usage<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT owner, SUM(bytes)\/1024\/1024 AS size_mb <br>FROM dba_segments <br>WHERE owner = 'DEV_USER' <br>GROUP BY owner;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd27 <strong>PART 2: Login as <code>DEV_USER<\/code> and Create Schema Objects<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd11 Connect<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">CONNECT dev_user\/\"P@ssw0rd\";<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcc2 Create and Populate Table<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE TABLE project_data ( id NUMBER, name VARCHAR2(100) );<br><br>BEGIN <br>  FOR i IN 1..10 LOOP <br>    INSERT INTO project_data VALUES (i, 'Item_' || i); <br>  END LOOP; <br>  COMMIT; <br>END; <br>\/<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2699\ufe0f Create Schema Objects<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE INDEX idx_proj_id ON project_data(id);<br><br>CREATE VIEW view_proj AS SELECT * FROM project_data WHERE id &lt;= 5;<br><br>CREATE SEQUENCE seq_proj START WITH 11 INCREMENT BY 1;<br><br>CREATE SYNONYM syn_proj FOR project_data;<br><br>CREATE OR REPLACE PROCEDURE add_data IS <br>BEGIN <br>  INSERT INTO project_data VALUES (seq_proj.NEXTVAL, 'Auto_Item'); <br>  COMMIT; <br>END; <br>\/<br><br>CREATE OR REPLACE FUNCTION fetch_name(p_id NUMBER) RETURN VARCHAR2 IS <br>  v_name VARCHAR2(100); <br>BEGIN <br>  SELECT name INTO v_name FROM project_data WHERE id = p_id; <br>  RETURN v_name; <br>END; <br>\/<br><br>CREATE OR REPLACE TRIGGER trg_upper_name <br>BEFORE INSERT ON project_data <br>FOR EACH ROW <br>BEGIN <br>  :NEW.name := UPPER(:NEW.name); <br>END; <br>\/<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\uddc2\ufe0f <strong>PART 3: Setup OS and Logical Directories<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\uddf1 Create OS Directories<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir -p \/u02\/dump\/export<br>mkdir -p \/u02\/dump\/import<br><br>chmod 777 \/u02\/dump\/export<br>chmod 777 \/u02\/dump\/import<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcc1 Create Oracle Logical Directories<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE OR REPLACE DIRECTORY exp_dir AS '\/u02\/dump\/export';<br>GRANT READ, WRITE ON DIRECTORY exp_dir TO dev_user;<br><br>CREATE OR REPLACE DIRECTORY imp_dir AS '\/u02\/dump\/import';<br>GRANT READ, WRITE ON DIRECTORY imp_dir TO dev_user;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcbe <strong>PART 4: Perform Tablespace Export<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">expdp dev_user\/\"P@ssw0rd\" DIRECTORY=exp_dir DUMPFILE=galaxy_exp.dmp LOGFILE=galaxy_exp.log TABLESPACES=galaxy<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcc4 Export Log Sample<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">Export: Release 19.0.0.0.0 - Production on Mon May 20 10:15:30 2025<br>Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0<br>Starting \"DEV_USER\".\"SYS_EXPORT_TABLESPACE_01\":<br>Processing object type TABLE_EXPORT\/TABLE\/TABLE_DATA<br>. . exported \"DEV_USER\".\"PROJECT_DATA\"               6.015 KB     10 rows<br>Master table \"DEV_USER\".\"SYS_EXPORT_TABLESPACE_01\" successfully loaded\/unloaded<br>******************************************************************************<br>Dump file set for DEV_USER.SYS_EXPORT_TABLESPACE_01 is:<br>  \/u02\/dump\/export\/galaxy_exp.dmp<br>Job \"DEV_USER\".\"SYS_EXPORT_TABLESPACE_01\" successfully completed<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\uddf9 <strong>PART 5: Optional Cleanup Before Import<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u274c Drop User (If Re-importing Cleanly)<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">DROP USER dev_user CASCADE;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd01 Recreate User and Objects<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Repeat <strong>PART 1<\/strong> and <strong>PART 2<\/strong> if necessary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udce4 <strong>PART 6: Copy Dump File &amp; Run Import<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\uddc2\ufe0f Copy Dump to Import Directory<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">cp \/u02\/dump\/export\/galaxy_exp.dmp \/u02\/dump\/import\/<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cp \/u02\/dump\/export\/galaxy_exp.dmp \/u02\/dump\/import\/<br># No error output means file copied successfully<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce5 Run Import Command<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">impdp dev_user\/\"P@ssw0rd\" DIRECTORY=imp_dir DUMPFILE=galaxy_exp.dmp LOGFILE=galaxy_imp.log TABLESPACES=galaxy TABLE_EXISTS_ACTION=REPLACE<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcc4 Import Log Sample<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">Import: Release 19.0.0.0.0 - Production on Mon May 20 10:20:42 2025<br>Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0<br>Master table \"DEV_USER\".\"SYS_IMPORT_TABLESPACE_01\" successfully loaded\/unloaded<br>Starting \"DEV_USER\".\"SYS_IMPORT_TABLESPACE_01\":<br>Processing object type TABLE_EXPORT\/TABLE\/TABLE<br>. . imported \"DEV_USER\".\"PROJECT_DATA\"              6.015 KB     10 rows<br>Processing object type TABLE_EXPORT\/TABLE\/INDEX\/INDEX<br>. . imported \"DEV_USER\".\"IDX_PROJ_ID\"<br>Processing object type TABLE_EXPORT\/TABLE\/CONSTRAINT\/CONSTRAINT<br>Processing object type TABLE_EXPORT\/TABLE\/TRIGGER<br>. . imported \"DEV_USER\".\"TRG_UPPER_NAME\"<br>Processing object type TABLE_EXPORT\/TABLE\/PROCEDURE\/PROCEDURE<br>. . imported \"DEV_USER\".\"ADD_DATA\"<br>Processing object type TABLE_EXPORT\/TABLE\/FUNCTION\/FUNCTION<br>. . imported \"DEV_USER\".\"FETCH_NAME\"<br>Processing object type TABLE_EXPORT\/TABLE\/VIEW<br>. . imported \"DEV_USER\".\"VIEW_PROJ\"<br>Processing object type TABLE_EXPORT\/TABLE\/SEQUENCE\/SEQUENCE<br>. . imported \"DEV_USER\".\"SEQ_PROJ\"<br>Processing object type TABLE_EXPORT\/TABLE\/SYNONYM<br>. . imported \"DEV_USER\".\"SYN_PROJ\"<br>Job \"DEV_USER\".\"SYS_IMPORT_TABLESPACE_01\" successfully completed at Mon May 20 10:20:56 2025<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 <strong>PART 7: Post-Import Validation<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce6 Check Imported Objects<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT object_name, object_type FROM user_objects;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd0d Verify Data<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT * FROM project_data;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2699\ufe0f Test Procedure and Function<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">EXEC add_data;<br>SELECT fetch_name(1) FROM dual;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd01 Verify Trigger Functionality<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">INSERT INTO project_data (id, name) VALUES (100, 'test');<br>SELECT * FROM project_data WHERE id = 100;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udfc1 <strong>Conclusion<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This guide walks you through a full tablespace-level export\/import within the same Oracle DB instance using <code>Data Pump<\/code>. The process is ideal for internal migrations, backups, or test environment setups.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Pro Tip<\/strong>: Always validate objects, permissions, and data integrity after import to avoid unexpected runtime issues.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Migrating a tablespace within the same Oracle DB instance can be useful for backup testing, development scenarios, or cloning environments. This step-by-step guide covers creating a dedicated tablespace, user setup, object creation, export\/import operations, and verification. \ud83e\uddf1 PART 1: Setup \u2013 Tablespace and User Creation \ud83d\udd0d Check Existing Tablespaces and Datafiles SELECT tablespace_name, file_name FROM [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowu461DA:productID":"","footnotes":""},"categories":[1225],"tags":[],"class_list":["post-3460","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/3460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/comments?post=3460"}],"version-history":[{"count":2,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/3460\/revisions"}],"predecessor-version":[{"id":3463,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/3460\/revisions\/3463"}],"wp:attachment":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=3460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=3460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/tags?post=3460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}