• Oracle导出表空间的创建语句、导入、导出dmp文件


    begin
     for c in (select t.NAME ,d.NAME  as name2 from v$tablespace t
    inner join  v$datafile d
    on t."TS#"=d."TS#"
    where t."TS#">4)
    loop
    dbms_output.put_line( 'create tablespace ' ||c.NAME || ' DATAFILE '||''''||c.name2||''''||' size 20M
    AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED;' );
    end loop;
    end;

    结果如:

    create tablespace EXAMPLE DATAFILE 'D:ORACLEORADATAORCLEXAMPLE01.DBF' size 20M
    AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED;
    create tablespace HCZZ_WEB_DATA DATAFILE 'D:ORACLEORADATAORCLDBF_HCZZ_WEB_DATA.DBF' size 20M
    AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED;
    create tablespace HCZZ_WEB_INDEX DATAFILE 'D:ORACLEORADATAORCLDBF_HCZZ_WEB_INDEX.DBF' size 20M
    AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED;

    数据库导出:

    --第一次新建数据库导入使用
    impdp hczz_web/password@localhost/orcl dumpfile=HCZZ_WEB_20170706.dmp
    impdp hczz_web/password@221.234.25.77/orcl dumpfile=HCZZ_WEB_20180502.dmp
    impdp hczz_web/password dumpfile=HCZZ_WEB_20170706.dmp
    --第二次导入使用
    impdp hczz_web/password dumpfile=HCZZ_WEB_20170706.dmp table_exists_action=replace --如果有替换还原新的数据库命,则执行---------------------- impdp hczz_web_test1/password@localhost/orcl dumpfile=HCZZ_WEB_20170628.DMP table_exists_action=replace remap_schema=hczz_web:hczz_web_test1 impdp hczz_web_test1/password@localhost/orcl dumpfile=HCZZ_WEB_20170628.DMP table_exists_action=replace remap_schema=hczz_web:hczz_web_test1 impdp hczz_web_test1/password@localhost/orcl dumpfile=备份库.DMP table_exists_action=replace remap_schema=原库名:现库名

    创建表空间

    /*分为四步 */
    /*第1步:创建临时表空间  */
    create temporary tablespace yuhang_temp 
    tempfile 'D:oracledatayuhang_temp.dbf' 
    size 50m  
    autoextend on  
    next 50m maxsize 20480m  
    extent management local;  
     
    /*第2步:创建数据表空间  */
    create tablespace yuhang_data  
    logging  
    datafile 'D:oracledatayuhang_data.dbf' 
    size 50m  
    autoextend on  
    next 50m maxsize 20480m  
    extent management local;  
     
    /*第3步:创建用户并指定表空间  */
    create user yuhang identified by yuhang  
    default tablespace yuhang_data  
    temporary tablespace yuhang_temp;  
     
    /*第4步:给用户授予权限  */
    grant connect,resource,dba to yuhang;

    创建用户

    DECLARE
       user_name              CONSTANT VARCHAR2 (64) := 'hczz_web';
       user_password          CONSTANT VARCHAR2 (64) := 'password';
       data_tablespace_name   CONSTANT VARCHAR2 (64) := 'hczz_web_data';
       temp_tablespace_name   CONSTANT VARCHAR2 (64) := 'hczz_web_temp';
    
       PROCEDURE p_execcmd (v_cmd IN VARCHAR2)
       AS
          v_cursorid   INTEGER;
       BEGIN
          v_cursorid := DBMS_SQL.open_cursor;
          DBMS_SQL.parse (v_cursorid, v_cmd, DBMS_SQL.native);
          DBMS_SQL.close_cursor (v_cursorid);
       EXCEPTION
          WHEN OTHERS
          THEN
             DBMS_SQL.close_cursor (v_cursorid);
             RAISE;
       END p_execcmd;
    BEGIN
    -------------------1.创建用户-----------------------------------------------
       p_execcmd (   'CREATE USER '
                  || user_name
                  || ' PROFILE DEFAULT IDENTIFIED BY '
                  || user_password
                  || ' DEFAULT TABLESPACE '
                  || data_tablespace_name
                  || ' TEMPORARY TABLESPACE '
                  || temp_tablespace_name
                  || ' ACCOUNT UNLOCK'
                 );
    -------------------2.授权---------------------------------------------------
    
     p_execcmd(  'GRANT CONNECT TO '||user_name||' WITH ADMIN OPTION' );
    
     p_execcmd(  'GRANT RESOURCE TO '||user_name||' WITH ADMIN OPTION'   );
    
    ---以下慎用,权限过大
     p_execcmd(  'GRANT DBA TO '||user_name||' WITH ADMIN OPTION'  );
    END;
  • 相关阅读:
    flask + supervisor + gunicorn
    sqlacodegen 的使用
    centos 安装 postgresql
    zipfile 压缩文件
    jmeter跨线程调用和线程内调用
    获取时间
    ant+jmeter环境配置
    Jenkins环境部署
    jmeter分布式性能测试部署
    怎么在Windows Server服务器上发布jsp网站
  • 原文地址:https://www.cnblogs.com/kk-home/p/9184860.html
Copyright © 2020-2023  润新知