为表增加字段与拷贝数据到另一个表
create database temp_DB
go
use temp_DB
go
--創(chuàng)建兩個(gè)表
create table t1
( sid nvarchar(50), sname nvarchar(50), type nvarchar(50) )
create table t2
( sid nvarchar(50), sname nvarchar(50), type nvarchar(50) )
go
為一個(gè)表t1增加一個(gè)字段
alter table t1 Add DrugName Varchar(80) null
為一個(gè)表t1刪除一個(gè)字段
alter table t2? drop column drugname
?
--插入數(shù)據(jù)
insert into t1
select '1','芯片' ,'t1',null union
select '2','天' ,'t1',null union
select '3','是的' ,'t1',null union
select '4','鼓勵(lì)' ,'t1',null union
select '5','誰(shuí)的' ,'t1',null union
select '6','天天' ,'t1',null
go
insert into t2
select '1',null,null union
select '2',null,null union
select '3',null,null union
select '5',null,null union
select '6',null,null
select * from t1 select * from t2
把一個(gè)表中的一個(gè)字段的數(shù)據(jù)插入到另一個(gè)表中去
update t2 set t2.sname=t1.sname from t1,t2 where t2.sid=t1.sid
轉(zhuǎn)載于:https://www.cnblogs.com/rongxiaoya/archive/2012/12/12/2814457.html
總結(jié)
以上是生活随笔為你收集整理的为表增加字段与拷贝数据到另一个表的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【NGN学习笔记】5 IMS技术
- 下一篇: Modulus 正式开放 —— Node