• oracle 快速复制一张表,并在此创建索引,日志及并行度


    复制表结构及其数据

    create table table_name_new as select * from table_name_old

    只复制表结构

    create table table_name_new as select * from table_name_old where 1=2

    只复制表数据

    insert into table_name_new select * from table_name_old

    表结构不一样

    insert into table_name_new(column1,column2...) select column1,column2... from table_name_old

    复制表结构及其数据不写日志

    create table table_name_new nologging as select * from table_name_old

    设置并行度

    create table testa2 (t1 int) parallel;

    commit;

    插入数据不写日志

    alter   table   table_name   NOLOGGING;

    再修改写日志

    alter   table   table_name   LOGGING;

    并行度:

    查看dba_tables数据字典时,可以发现有“DEGREE”字段,这个字段表示的就是数据表的并行度。这个参数的设置,关系着数据库的I/O,以及sql的执行效率。当设置表的并行度非常高的时候,sql优化器将可能对表进行全表扫描,引起 Direct Path Read 等待 。

    在使用并行查询前需要慎重考虑, 因为并行查询尽管能提高程序的响应时间, 但是会

    消耗比较多的资源。

    alter table t parallel(degree 1);------直接指定表的并行度

    alter table t parallel;    ----------设置表的并行度为default

    创建索引:

    create [unique] index index_name on table_name(column_name[,column_name…])

  • 相关阅读:
    C#对象初始化器
    C#构造方法
    C#方法重载
    C#方法
    C#类 对象 字段和属性
    C#数组
    C#字符串
    C#原码反码补码
    字段、方法、属性
    单例模式、异常
  • 原文地址:https://www.cnblogs.com/lingbing/p/6386921.html
Copyright © 2020-2023  润新知