oracle 创建数据库

查询表空间的命令

 select t1.name,t2.name 

         from v$tablespace t1,v$datafile t2

         where t1.ts# = t2.ts#;
         
CREATE TABLESPACE ORM_342_BETA
DATAFILE '/app/oracle/oradata/sysware/ORM_342_BETA.DBF' size 800M         --存储地址 初始大小800M
    autoextend on next 50M maxsize unlimited                   --每次扩展10M,无限制扩展
         EXTENT MANAGEMENT LOCAL autoallocate SEGMENT SPACE MANAGEMENT AUTO;   


CREATE TABLESPACE SYSWARE_ORM_340_UPGRADE
DATAFILE '/app/oracle/oradata/sysware/SYSWARE_ORM_340_UPGRADE.DBF' size 800M      
    autoextend on next 50M maxsize unlimited                  
         EXTENT MANAGEMENT LOCAL autoallocate SEGMENT SPACE MANAGEMENT AUTO;   
1.切换oracle用户:
    su - oracle
2.进入sql 
    sqlplus sys/sysware@sysware as sysdba
3.创建权限目录,用sysdba登陆,在sql窗口执行(或者cmd窗口执行:sqlplus /@sysware(在那个数据库实例中) as sysdba)
    create directory 授权目录名 as '授权目录';   
    grant read,write on directory 授权目录名 to 数据库用户名;
如:
    create directory DPDIROEM20230414 as '/syswareIDP/dpdir/DPDIROEM20230414';   
    grant read,write on directory DPDIROEM20230414 to SYSWARE_ORM_340_UPGRADE;
    
    
    create directory dpdir1201 as '/syswareIDP/dpdir/dpdir1201';   
    grant read,write on directory dpdir1201 to SYSWARE_ORM_MR;

4.导入,在cmd窗口执行
impdp 数据库用户名/数据库密码 directory=授权目录名 remap_tablespace=导出数据库的表空间:表空间 dumpfile=数据文件名称.dmp remap_schema=导出数据库的用户名:数据库用户名 transform=OID:N
如:
impdp IDP_20200612/IDP_20200612@sysware directory=dpdir220200612 remap_tablespace=idp_20170313:IDP_20200612 dumpfile=DATA.DMP remap_schema=idp_20170313:IDP_20200612 transform=OID:N


impdp SYSWARE_ORM_340_UPGRADE/SYSWARE_ORM_340_UPGRADE@sysware directory=DPDIROEM20230414 remap_tablespace=SYSWARE_ORM_342_DEMO:SYSWARE_ORM_340_UPGRADE dumpfile=kmdata_exp.dmp remap_schema=SYSWARE_ORM_342_DEMO:SYSWARE_ORM_340_UPGRADE transform=OID:N


impdp SYSWARE_ORM_343_VERSION/SYSWARE_ORM_343_VERSION@sysware directory=DPDIROEM230704 remap_tablespace=SYSWARE_343_DEMO:SYSWARE_ORM_343_VERSION dumpfile=data.dmp   remap_schema=SYSWARE_343_DEMO:SYSWARE_ORM_343_VERSION transform=OID:N

SYSWARE_343_DEMO

--sqlplus IDP_20200612/IDP_20200612@localhost:1521/sysware
--查看帮助
expdp -help
impdp -help

         

你可能感兴趣的:(oracle,数据库)