zoukankan      html  css  js  c++  java
  • oracle、mysql、sybase和sqlserver复制表结构和数据

    转自该博主,谢谢其作出的贡献,https://www.cnblogs.com/rwxwsblog/p/4506016.html

    Sql Server(sybase):

    1.复制表结构:

    新建表student2,并且结构同表syn_xj_student一致。Sql语句如下:

    select * into syn_xj_student2 from syn_xj_student where 1=2

    2.复制表数据,并排除俩表中相同的数据:

    insert into syn_xj_student2 select * from syn_xj_student where f_id not in (select f_id from syn_xj_student2)

    mysql:

    1.复制表结构:

    create table topic like bbs_topic

    2.复制表数据:

    INSERT into topic SELECT * FROM bbs_topic

    3.复制整个表:

    CREATE TABLE new_table SELECT * FROM old_table;

    Oracle:

    1.复制表结构

    create table 用户名.表名 as select * from 用户名.表名 where 1=2

    2.同用户表之间的数据复制

    用户B下有两个表:B.x和B.y,如果需要从表x转移数据到表y,使用用户B登陆sqlpus即可:

    insert into y select * from x;

    3.B.x中个别字段转移到B.y的相同字段

    insert into y(字段1,字段2) select 字段1,字段2 from

    4.不同用户之间的表数据复制

    对于在一个数据库上的两个用户A和B,假如需要把A下表old的数据复制到B下的new,请使用权限足够的用户登入sqlplus:

    insert into B.newTable(select * from A.oldTable);

    如果需要加条件限制,比如复制当天的A.oldTable数据

    insert into B.newTable(select * from A.oldTable where date=GMT);
  • 相关阅读:
    Linux 安装SonarQube
    Linux 安装postgresql
    如何为chrome浏览器设置socks5代理
    echarts tab切换宽度变为100px解决方案
    将url参数转为对象
    一行js代码实现时间戳转时间格式
    解决问题的方法论
    李笑来的幻灯课
    随便写写(最近更新于2021/07/18早)
    谈谈装系统这件事
  • 原文地址:https://www.cnblogs.com/fajieyefu/p/8067200.html
Copyright © 2011-2022 走看看