自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL Server 中Select into復制數(shù)據(jù)到新表

數(shù)據(jù)庫 SQL Server
本篇帶給大家在SQL Server中使用 select into 可以創(chuàng)建一張新表的同時將原有表數(shù)據(jù)追加到新表中的相關知識。希望能夠幫助到你!

[[396980]]

 在SQL Server中使用 select into 可以創(chuàng)建一張新表的同時將原有表數(shù)據(jù)追加到新表中,現(xiàn)在創(chuàng)建一張測試表,里面存放各城市大學名稱:

  1. create table [dbo].[school]( 
  2. [id] [bigint] identity(1,1) not null
  3. [name] [varchar](50) not null
  4. [cityid] [bigintnot null
  5. constraint [school_primary] primary key clustered  
  6.  
  7. [id] asc 
  8.  ) 

 為測試表創(chuàng)建以cityid為索引列的非聚集索引:

  1. create nonclustered index [index_school_cityid] on [dbo].[school] ([cityid] asc

追加數(shù)據(jù)后,查看該表的數(shù)據(jù):

  1. select * from school 

 

現(xiàn)在使用 select into 復制一張新表school_test:

  1. select * into school_test from school 

查看新表school_test的數(shù)據(jù),和原有表schoo相同:

  1. select * from school_test 

再來看看新表的結構,發(fā)現(xiàn)id的自增屬性被復制了:

而其他的屬性,如原表的主鍵和索引卻沒有被復制到新表:

說明使用select into 可以復制原表的數(shù)據(jù)、字段和自增屬性,而主鍵和索引等卻無法被復制。

 

責任編輯:姜華 來源: 今日頭條
相關推薦

2010-11-23 14:58:05

MySQL復制表數(shù)據(jù)

2010-11-11 10:18:59

select into

2010-07-15 17:57:48

SQL Server數(shù)

2010-11-11 11:00:06

sql server遍

2011-01-13 08:47:49

SQL Server數(shù)

2011-04-02 16:20:21

SQL SERVER 同步復制

2010-09-16 14:13:11

SQL Server系

2011-07-28 18:08:51

SQL Server MySQL

2010-10-20 14:56:18

2010-05-13 10:00:10

SQL Server

2011-04-12 09:07:50

復制數(shù)據(jù)庫SQL 2008

2010-07-09 11:28:12

SQL Server數(shù)

2010-10-21 15:13:20

SQL Server系

2010-10-20 14:23:28

SQL Server復

2011-03-29 13:22:07

SQL Server臨時表表變量

2010-07-19 11:01:55

SQL Server

2010-07-22 16:02:29

2011-08-15 17:55:49

提取MapInfo地圖SQL Server

2010-09-03 15:27:02

SQLSELECT語句

2010-09-03 15:17:18

SQLselect語句
點贊
收藏

51CTO技術棧公眾號