导入/导出数据库有些错误

时间:2015-11-16 08:09:16

标签: oracle plsql oracle11g

我将数据库导出为:

exp system/passwd owner=weblogics file=/var/Downloads/dmp/weblogics61015.dmp log=/var/Downloads/dmp/weblogics61015.log statistics=none  

Importing database as:
imp system/passwd fromuser=weblogics touser=weblogics file=/var/Downloads/dmp/weblogics61015.dmp log=/dmp/weblogics61015.log   

SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production 


SQL> select distinct tablespace_name from dba_segments where owner='weblogics';


no rows selected

为什么我无法看到我的表空间。我该怎么办?

1 个答案:

答案 0 :(得分:0)

1)所有者名称必须是大写字母,如WEBLOGICS而不是weblogics 2)你使用11g所以我强烈建议使用datapump而不是imp / exp。

您的对象当前存在于源数据库的SYSTEM表空间中,它们将在新数据库的系统表空间中创建,因为表的DDL将如下所示:

create table weblogics.tableName (col1) tablespace system;

请按照以下步骤操作:

   SQL> SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';

    DIRECTORY_PATH
    --------------------------------------------------------------------------------
    D:\Oracle\app\PC-NAME/admin/xe/dpdump/


    SQL> SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';

    DIRECTORY_PATH
    --------------------------------------------------------------------------------
    /u01/app/oracle/admin/XE/dpdump/


    SQL> CREATE DIRECTORY dmpdir AS 'D:\Oracle\app\PC-NAME\admin\XE\dpdump\dmpdir';
    Directory created.

    SQL> GRANT read, write ON DIRECTORY dmpdir TO WEBLOGICS;
    Grant succeeded.

现在您可以导出为:

    expdp WEBLOGICS/pass DIRECTORY=dmpdir DUMPFILE=WEBLOGICS.dmp logfile=WEBLOGICS.log SCHEMAS=WEBLOGICS

现在将SYSTEM转移到WEBLOGICS,请按照以下步骤操作:

create TABLESPACE WEBLOGICS
DATAFILE 'D:\Oracle\app\PC-NAME\oradata\XE\WEBLOGICS01.dbf' SIZE 10M
AUTOEXTEND ON
NEXT 512K
MAXSIZE 250M;

SQL> drop user WEBLOGICS cascade;

User dropped.

SQL> create user WEBLOGICS identified by pass;

User created.

SQL> grant connect, resource to WEBLOGICS;

Grant succeeded.

SQL> grant read, write on directory dmpdir to WEBLOGICS;

Grant succeeded.

SQL> grant create database link to WEBLOGICS;

Grant succeeded.

现在导入数据:

impdp WEBLOGICS/WEBLOGICS 
remap_tablespace=SYSTEM:WEBLOGICS 
dumpfile=WEBLOGICS.dmp directory=dmpdir

现在你可以确认一下:

SQL> select diPC-NAMEnct tablespace_name from dba_segments where owner='WEBLOGICS';

干杯!!