zoukankan      html  css  js  c++  java
  • Oracle Copy From命令

    一 用途

    Copy 命令是SQL*Plus命令,可用于在ORACLE数据库、非ORACLE数据库之间数据的传输。

    二 语法结构

    SQL> copy
    
    usage: COPY FROM <db> TO <db> <opt> <table> { (<cols>) } USING <sel>
    
    <db> : database string, e.g., hr/your_password@d:chicago-mktg
    
    <opt> : ONE of the keywords: APPEND, CREATE, INSERT or REPLACE
    
    <table>: name of the destination table
    
    <cols> : a comma-separated list of destination column aliases
    
    <sel> : any valid SQL SELECT statement
    
    A missing FROM or TO clause uses the current SQL*Plus connection.

    COPY {FROM database | TO database | FROM database TO database} {APPEND|CREATE|INSERT|REPLACE} destination_table [(column, column, column, ...)] USING query

    1 语法说明:

    1)FROM database

    需要Copy数据的数据库,即源数据库,如果忽略该子句,源库默认为正在连接的数据库,如果连接远端数据库,必须指定该子句,不支持SYSDBA或SYSOPER权限进行连接;

    2)TO database

    包含目标表的数据库,即目标库,如果忽略该子句,目标库默认为正在连接的数据库,如果连接远端数据库,必须指定该子句,不支持SYSDBA或SYSOPER权限进行连接;

    3)database

    username[/password]@connect_identifier;

    4)APPEND

    如果目标表存在,将查询的数据行插入目标表,若目标表不存在,创建表并插入数据行;

    5)CREATE

    如果目标表不存在,创建目标表,并插入数据行,如果目标表存在,返回错误;

    6)INSERT

    如果目标表存在,将查询的数据行插入目标表,若目标表不存在,返回错误;

    7)REPLACE

    如果目标表存在,删除表并创建表,插入数据,如果目标表不存在,创建表,插入数据;

    8)destination_table

    目标表;

    9)(column, column, column, ...)

    指定目标表的列名;

    10)USING query

    指定查询语句,决定Copy的行和列;

    2 支持的数据类型

    Copy指令支持下面的数据类型:

    • Char;
    • Date;
    • Long;
    • Number;
    • Varchar2;

    3 参数设置

    Copy命令可以使用如下参数来控制该指令的一些行为,分别是:

    1)Set Long变量

    用于限制Long列的长度,如果列过长,则会截断超过该参数的长度;

    2)Set Arraysize变量

    用于限制每次从数据库获取的数据行数,对应的数据行数组成一个批次;

    3)Set Copycommit变量

    用于设置提交更改至数据库对应的批次数量;

    三 示例

    SQL> set arraysize 5000;
    
    SQL> set copycommit 40;
    
    SQL> copy from scott/scott@orcl to scott/scott@orcl insert scott.t_copy using select *from scott.t_test;
    
    
    
    Array fetch/bind size is 5000. (arraysize is 5000)
    
    Will commit after every 40 array binds. (copycommit is 40)
    
    Maximum long size is 80. (long is 80)
    
    5587968 rows selected from scott@orcl.
    
    5587968 rows inserted into SCOTT.T_COPY.
    
    5587968 rows committed into SCOTT.T_COPY at scott@orcl.

  • 相关阅读:
    tomcat日志警告WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '0' did not find a matching property.
    针对数据泵导出 (expdp) 和导入 (impdp)工具性能降低问题的检查表 (文档 ID 1549185.1)
    DATAPUMP PERFORMANCE EXPDP IS VERY SLOW 10.2.0.4 TO 11.2.0.2
    oracle已知会导致错误结果的bug列表(Bug Issues Known to cause Wrong Results)
    如何进行oracle capability i/o(压力测试数据库服务器i/o性能)
    RMAN备份与恢复之删除过期备份
    DBA常用SQL之表空间与数据文件
    DBA常用SQL之会话与等待事件
    Oracle监控代理安装ITM(IBM Tivoli Monitoring)
    linux 命令之系统活动报告sar
  • 原文地址:https://www.cnblogs.com/alen-liu-sz/p/12975611.html
Copyright © 2011-2022 走看看