四、导入全库 1.在WINDOWS上做一些修改方便以后导入的验证 (1)修改用户SCOTT模式下表EMP的数据 SQL>conn scott/tiger 已连接。 SQL> select ename,sal from emp;
ENAME SAL ---------- ---------- SMITH 800 ALLEN 1600 WARD 1250 JONES 2975 MARTIN 1250 BLAKE 2850 CLARK 2450 SCOTT 3000 KING 5000 TURNER 1500 ADAMS 1100 JAMES 950 FORD 3000 MILLER 1300
已选择14行。
SQL> delete from emp where ename='JAMES';
已删除 1 行。
SQL> update emp set sal=2600 where ename='ALLEN';
已更新 1 行。
SQL> select ename,sal from emp;
ENAME SAL ---------- ---------- SMITH 800 ALLEN 2600 WARD 1250 JONES 2975 MARTIN 1250 BLAKE 2850 CLARK 2450 SCOTT 3000 KING 5000 TURNER 1500 ADAMS 1100 FORD 3000 MILLER 1300
已选择13行。
SQL> commit;
提交完成。
(2)新建一个表空间lianxi SQL> conn / as sysdba 已连接。 SQL> select name from v$datafile;
NAME --------------------------------------------------------------------------------
F:\DATABASE\INSTALL\ORADATA\ORCL\SYSTEM01.DBF F:\DATABASE\INSTALL\ORADATA\ORCL\SYSAUX01.DBF F:\DATABASE\INSTALL\ORADATA\ORCL\UNDOTBS01.DBF F:\DATABASE\INSTALL\ORADATA\ORCL\USERS01.DBF F:\DATABASE\INSTALL\ORADATA\ORCL\EXAMPLE01.DBF
SQL> create tablespace lianxi datafile 'F:\DATABASE\INSTALL\ORADATA\ORCL\lianxi01.dbf' size 10m;
表空间已创建。
(3)新创建一个用户lx并指定其默认表空间为lianxi SQL> create user lx identified by lx 2> default tablespace lianxi 3> temporary tablespace temp;
用户已创建。
(4)给用户lx授权 SQL> grant connect,resource to lx;
授权成功。
(5)用用户lx新建一张表并插入一些数据 SQL> conn lx/lx 已连接。
SQL> create table tt(name varchar2(20),age number);
表已创建。
SQL> insert into tt values('KOBE',21);
已创建 1 行。
SQL> insert into tt values('WADE',43);
已创建 1 行。
SQL> insert into tt values('WANG',19);
已创建 1 行。
SQL> insert into tt values('JAMES',27);
已创建 1 行。
SQL> insert into tt values('BIRD',23);
已创建 1 行。
SQL> SELECT * FROM TT;
NAME AGE -------------------- ---------- KOBE 21 WADE 43 WANG 19 JAMES 27 BIRD 23
SQL> commit;
提交完成。
2.查看有哪些表空间 SQL> conn / as sysdba 已连接。 SQL> select tablesapce_name from dba_tablespaces;
TABLESPACE_NAME
-------------------------
UNDOTBS1
SYSAUX USERS SYSTEM EXAMPLE LIANXI
已选择6行。
3.进行全库的导出 C:\Documents and Settings\Administrator>exp 'sys/oracle as sysdba' file=f:\exp\exp_full.dmp full=y log=f:\exp\exp_full.log
Export: Release 11.2.0.3.0 - Production on 星期二 10月 16 16:24:34 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出整个数据库... . 正在导出表空间定义 ............... ............... 正在导出统计信息 导出成功终止, 但出现警告。
4.查看linux中oracle数据库有哪些表空间 SQL> conn / as sysdba connected. SQL>select tablesapce_name from dba_tablespaces;
TABLESPACE_NAME
-------------------------
UNDOTBS1
SYSAUX USERS SYSTEM EXAMPLE
5.创建表空间lianx SQL> select name from v$datafile;
NAME -------------------------------------------------------------------------------- /oracle/app/oracle/oradata/sztech1/system01.dbf /oracle/app/oracle/oradata/sztech1/sysaux01.dbf /oracle/app/oracle/oradata/sztech1/undotbs01.dbf /oracle/app/oracle/oradata/sztech1/users01.dbf /oracle/app/oracle/oradata/sztech1/example01.dbf
SQL> create tablespace lianxi datafile '/oracle/app/oracle/oradata/sztech1/lianxi01.dbf' size 10m;
Tablespace created.
6.查看用户SCOTT下表EMP的数据 SQL> conn scott/tiger Connected. SQL> select ename,sal from emp;
ENAME SAL ---------- ---------- SMITH 800 ALLEN 1600 WARD 1250 JONES 2975 MARTIN 1250 BLAKE 2850 CLARK 2450 SCOTT 3000 KING 5000 TURNER 1500 ADAMS 1100 JAMES 950 FORD 3000 MILLER 1300
14 rows selected.
7.上传WINDOWS中导出的文件 [oracle@dbserver ~]$ pwd /home/oracle [oracle@dbserver ~]$ ls oradiag_oracle [oracle@dbserver ~]$ rz rz waiting to receive. Starting zmodem transfer. Press Ctrl+C to cancel. Transferring exp_full.dmp... 100% 146324 KB 5225 KB/s 00:00:28 0 Errors [oracle@dbserver ~]$ ls exp_full.dmp oradiag_oracle
8.删除SCOTT用户下的emp表 SQL>conn scott/tiger connected. SQL>drop table emp; TABLE DROPED.
9.进行全库导入 [oracle@dbserver ~]$ imp \'/ as sysdba\' file=exp_full.dmp full=y log=imp_full.log ignore=y
Import: Release 11.2.0.1.0 - Production on Tue Oct 16 16:47:56 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
............................ ............................
Import terminated successfully with 3042 errors.
10.进行确认 SQL>conn / as sysdba
connected.
SQL> select tablesapce_name from dba_tablespaces;
TABLESPACE_NAME
-------------------------
UNDOTBS1
SYSAUX USERS SYSTEM EXAMPLE LIANXI
SQL> conn lx/lx Connected. SQL> select * from tt;
NAME AGE -------------------- ---------- KOBE 21 WADE 43 WANG 19 JAMES 27 BIRD 23
SQL> conn scott/tiger Connected. SQL> select ename,sal from emp;
ENAME SAL ---------- ---------- SMITH 800 ALLEN 2600 WARD 1250 JONES 2975 MARTIN 1250 BLAKE 2850 CLARK 2450 SCOTT 3000 KING 5000 TURNER 1500 ADAMS 1100 FORD 3000 MILLER 1300
13 rows selected.
导入成功。 |