检索一个表中的部分行存到另一张表中。

一 、另外的那张表没有新建的时候,使用 select XXX into,创建的表与原表有相同的列名和类型:

select *
into Departments_Copy
from Departments
where Departments.ID>100

二、另外的那张表已经新建的时候,使用Insert into XXX select:

insert into Departments_Copy
select *
from Departments

select XXX into 和 Insert into XXX select的更多相关文章

  1. 拒绝了对对象 'data'(数据库 'xxx',所有者 'dbo')的 SELECT 权限

    拒绝了对对象 'data'(数据库 'xxx',所有者 'dbo')的 SELECT 权限解决的方法:1>在数据库里相应的用户权限中,把db_denydatareader的复选框的勾去掉.很多初 ...

  2. PostgreSQL simple select(group by and insert into ...select)

    warehouse_db=# create table student(number int primary key,name varchar(20),age int);CREATE TABLEwar ...

  3. select into from 和 insert into select 的用法和区别

    select into from 和 insert into select都是用来复制表,两者的主要区别为: select into from 要求目标表不存在,因为在插入时会自动创建.insert ...

  4. select into from和insert into select from两种表复制语句区别

    select into from和insert into select from两种表复制语句都是将源表source_table的记录插入到目标表target_table,但两句又有区别. 第一句(s ...

  5. select into from 和 insert into select 的用法和区别(转)

    转自:http://www.studyofnet.com/news/182.html select into from 和 insert into select都是用来复制表,两者的主要区别为: se ...

  6. 表复制语句select into from 与 insert into select 区别鉴赏

    select into from 与 insert into select 区别鉴赏 1.INSERT INTO SELECT语句 语句形式为:Insert into Table2(field1,fi ...

  7. Mysql中Insert into xxx on duplicate key update问题

    要点:Insert into xxx on duplicate key update可以在唯一索引重复的情况下,进行更新操作.           (1) 插入里边的字段应该只有一个 唯一索引:   ...

  8. select into from 和 insert into select 的用法

    SELECT INTO 和 INSERT INTO SELECT 两种表复制语句 Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) valu ...

  9. select into from和insert into from

    最近在研究oracle function 时发现select into from和insert into from,这样的语句,于是上网查阅资料学习了一下, 原来两种表达式均可以达到复制整个表或表的一 ...

随机推荐

  1. python pdb调试模块使用

    一般在需要调试的文件加入下面代码即可 ################ _DEBUG = True ... if _DEBUG == True import pdb pdb.set_trace() # ...

  2. MyEclipse Blue Edition 6.5 注册码生成程序

    import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; im ...

  3. sql server 读取表结构

    SELECT 表名 then d.name else '' end, 字段序号=a.colorder, 主键 FROM sysobjects where xtype='PK' and name in ...

  4. IOS键盘收起

    1.点击Return按扭时收起键盘 - (BOOL)textFieldShouldReturn:(UITextField *)textField { return [textField resignF ...

  5. shell/bash 交集、并集、差集

    方法一(直接用文件名):取两个文本文件的并集.交集.差集并:sort -m <(sort file1 | uniq) <(sort file2 | uniq) | uniq交:sort - ...

  6. bzoj3672

    感觉是noi2014中最有价值的一道题了 我们先考虑链上这个问题怎么做…… 如果没限制,那就是SB的斜率优化 我们可以得到这个式子(f[j]-f[k])/(s[j]-s[k])<p[i] 点横坐 ...

  7. Jqgrid入门-显示基本的表格(一)

    首先对Jqgrid网格插件做个简要的说明.在众多的表格插件中,Jqgrid的特点是非常鲜明的.         特点如下: 完整的表格呈现与运算功能,包含换页.栏位排序.grouping.新增.修改及 ...

  8. Java [Leetcode 219]Contains Duplicate II

    题目描述: Given an array of integers and an integer k, find out whether there are two distinct indices i ...

  9. ffmpeg/ffplay vc6 源码剖析

    ffmpeg/ffplay是当今多媒体领域的王者,很多很多的人想研究学习ffmpeg/ffplay,但苦于ffmpeg/ffplay庞大的代码量,令人望而生畏.为帮助更多的人研习ffmpeg/ffpl ...

  10. Mybatis学习——一对一关联表查询

    1.SQL语句建表 CREATE TABLE teacher( t_id ) ); CREATE TABLE class( c_id ), teacher_id INT ); ALTER TABLE ...