??? ?? ?????? ??????
??? ?? ?????? ??????
??? ?? ?????? ??????
com
Overview
1. Use Create Table As Select (CTAS) to directly create a table with the specific columns you need.
2. Utilize the Export and Import functionality, and then drop the unnecessary columns from the
target table.
3. If you're using Oracle Database 12c or higher, take advantage of the VIEW_AS_TABLES feature.
Use Create Table As Select (CTAS) to directly create a table with the
specific columns you need.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> def
DEFINE _DATE = "09-AUG-24" (CHAR)
DEFINE _CONNECT_IDENTIFIER = "test1" (CHAR)
DEFINE _USER = "SYS" (CHAR)
DEFINE _PRIVILEGE = "AS SYSDBA" (CHAR)
DEFINE _SQLPLUS_RELEASE = "1903000000" (CHAR)
DEFINE _EDITOR = "vi" (CHAR)
DEFINE _O_VERSION = "Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0" (CHAR)
DEFINE _O_RELEASE = "1903000000" (CHAR)
SQL>
Create a Table using CTAS method with all Columns of another DB objects
Create another Table using CTAS Method, but this time we are creating table using
specific columns.
Table created.
Now plan for exporting table with specific columns from source and exporting it in
target using “REMAP_TABLE” Parameter.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Username: / as sysdba
Password:
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Starting "SYS"."SYS_EXPORT_TABLE_01": /******** AS SYSDBA directory=EXP_IMP
dumpfile=expdp_tb1_haldiram_backup.dmp logfile=expdp_tb1_haldiram_backup.log
tables=ram.tb1_haldiram_backup
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "RAM"."TB1_HALDIRAM_BACKUP" 3.627 MB 72476 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
/u01/export_import/expdp_tb1_haldiram_backup.dmp
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Username: / as sysdba
Password:
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Master table "SYS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TABLE_01": /******** AS SYSDBA directory=EXP_IMP
dumpfile=expdp_tb1_haldiram_backup.dmp logfile=impdp_tb1_haldiram_backup.log
tables=ram.tb1_haldiram_backup remap_table=ram.tb1_haldiram_backup:tb2_haldiram_backup
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "RAM"."TB2_HALDIRAM_BACKUP" 3.627 MB 72476 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Job "SYS"."SYS_IMPORT_TABLE_01" successfully completed at Fri Aug 9 23:19:43 2024 elapsed 0
00:00:41
[oracle@localhost_dest ~]$
Utilize the Export and Import functionality, and then drop the
unnecessary columns from the target table.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Starting "SYS"."SYS_EXPORT_TABLE_01": /******** AS SYSDBA directory=EXP_IMP
dumpfile=expdp_view_haldiram.dmp logfile=expdp_view_haldiram.log
VIEWS_AS_TABLES=ram.view_haldiram
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
. . exported "RAM"."VIEW_HALDIRAM" 3.417 MB 72584 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
/u01/export_import/expdp_view_haldiram.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at Sat Aug 10 01:13:17 2024 elapsed 0
00:00:18