测试用户连接
C:UsersP>sqlplus /nolog
conn hbcxuser/hbcxpass
创建表空间
C:UsersP>sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期三 7月 10 11:33:19 2019
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> conn sys/Oracle11g as sysdba
已连接。
SQL> create tablespace ORCL_HBCX datafile 'E:ProgramFilesOracleDatabaseORCL_HBCX_DATA.DBF' size 300m autoextend on;
表空间已创建。
SQL> create temporary tablespace ORCL_HBCX_TEMP tempfile 'E:ProgramFilesOracleDatabaseORCL_HBCX_TEMP.DBF' size 100m autoextend on next 50m maxsize 2048m extent management local;
表空间已创建。
SQL> create user hbcxuser identified by hbcxpass default tablespace ORCL_HBCX temporary tablespace ORCL_HBCX_TEMP profile default account unlock;
用户已创建。
SQL> grant connect to hbcxuser;
授权成功。
SQL> grant dba to hbcxuser;
授权成功。
SQL> grant resource to hbcxuser;
授权成功。
SQL> alter user hbcxuser default role all;
用户已更改。
SQL> grant unlimited tablespace to hbcxuser;
授权成功。
SQL> exit;
imp hbcxuser/hbcxpass@orcl file=E:ProgramFilesOracleDatabasehbsjwj.dmp FULL=y
imp hbcxuser/hbcxpass@orcl file=D:DatabasesDatas20191129.dmp FULL=y
SELECT 'drop table '|| table_name || ';' FROM USER_TABLES ORDER BY TABLE_NAME;
exp gfuser01/gfuser01@10.30.47.212:1521/ZODTZ file=c:EAM_20150929_PRE-PRODUCTION_GF.dmp
exp hbcxuser/hbcxpass@localhost/ORCL file=E:ProgramFilesOracleDatabase20191101.dmp
grants=Y rows=Y full=Y
----------------------删除表结构
SELECT 'DROP TABLE ' || TABLE_NAME || ' CASCADE CONSTRAINTS' V_NAME
FROM DBA_TABLES
WHERE TABLESPACE_NAME = 'USERS';
-----------
select d.file_name,d.tablespace_name,d.autoextensible from dba_temp_files d;
select tablespace_name, bytes, user_bytes, user_bytes/bytes,file_name from dba_temp_files;
ALTER DATABASE tempfile 'E:ProgramFilesOracleDatabaseORCL_HBCX_TEMP.DBF' AUTOEXTEND ON maxsize 8g;
--------------------------------
su - oracle
expdp hbcxuser/hbcxpass@ORCL directory=data dump=expdp_ORCL_HBCS_20200429.dmp logfile=ORCL_hbcx.log schemas=hbcxuser
rman 备份
rman target /
backup tablespace ORCL_HBCX FORMAT='/oradata/oraback/rman_tablespace_%N_%f_%s.dmp';
13:51
rman_tablespace_%N_%f_%s.dmp 这个再备份可以改成你自己定义的名字
导入------------------
前提先把dmp文件放到Oracle安装目录下
1 impdp hbcxusera/hbcxpassa dumpfile=20200813.dmp full=y REMAP_SCHEMA=hbcxuser:hbcxusera EXCLUDE=USER;
REMAP_SCHEMA=旧帐号:新账号
2. 导入用户 impdp user2/pass2 directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2 EXCLUDE=USER
方法二 :需要先删除表和视图,不然是追加方式不是覆盖
imp hbcxusera/hbcxpassa dumpfile=20200813.dmp full=y ignore=y;
如果想导入的用户不存在:
1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp
2. 导入用户 impdp system/passsystem directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2
3. user2会自动建立,其权限和使用的表空间与user1相同,但此时用user2无法登录,必须修改user2的密码