zoukankan      html  css  js  c++  java
  • sql表与表之间的数据操作

    --把一张表的内容更新到另一张表
    update 表1
    set 表1.Store=t2.Name
    from 表2 t2 where 表1.id=t2.id
    
    
    --备份一张表
    create table tab_new like tab_old (使用旧表创建新表)
    create table tab_new as select col1,col2… from tab_old definition only
    --(试了以上两句无效)
    select * into newtable from oldtable; 如果不想导记录,只想生成表结构 :select * into newtable from oldtable where 1=2;
    如果newtable已存在,想导入记录:insert into newtable select * from oldtable where ...
    
    
    --sqlserver复制表数据到另一个表
    SQL Server中如果目标表存在:
    insert into 目标表 select * from 原表;
    SQL Server中,如果目标表不存在:
    select * into 目标表 from 原表;
  • 相关阅读:
    PTA9
    PTA8
    第七周
    第六周
    第五周
    PTA4
    2019第三次作业
    第十周课程总结
    第九周课程总结&实验报告(七)
    第八周课程总结&实验报告(六)
  • 原文地址:https://www.cnblogs.com/oneall/p/10773066.html
Copyright © 2011-2022 走看看