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