将dmp数据导入到另一个表

    偶然看到有人问, 如何将A表导出的dmp文件导入到B表中, 初一看, 的确好象是不行, 其实还是有办法的. 先来建一个测试环境吧!

SQL> create table t_a as select * from tab;

Table created.

SQL> create table t_b as select * from tab where rownum < 1;

Table created.

    任务是将T_A表导出的记录导入到T_B表中, 所以我在SYSTEM用户中建了一个同义词.

SQL> create synonym t_a for mydul.t_b;

Synonym created.

    接下来的导出和导入命令, 你自已去试试吧.

exp mydul/mydul file=t_a.dmp tables=t_a
imp system/oracle file=t_a.dmp fromuser=mydul touser=system ignore=y

    验证一下数据有没有导入进去.

SQL> select count(*) from t_b;

  COUNT(*)
----------
        17

SQL> select count(*) from t_a;

  COUNT(*)
----------
        17

    Oracle的imp导入数据时, 也只不过是运行Insert语句而已, 向同义词和向表, 它分得清吗?

留言 (2)

从来没想过还可以这样搞,强!

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

我在我的数据库上实验了,提示导入成功,可是t_b里没插入数据!
为什么非system不行!

发表留言:

« Previous | Main | Next »

英语900句 | English 900

  • It's December.
  • 现在是十二月.
  • What year is this?
  • 今年是哪一年?
  • It's the year of 1999.
  • 今年是1999年.
  • What will you do during this weekend?
  • 这周末你干什么?
  • Does the shop open at 9 am on weekdays?
  • 这家店平日是早上9点开门吗?