sqlserver进阶必会基础入门不止select into from 插入数据必知

  



--select into 从一个表复制数据值内容到另外一个表里面,把数据插入到另外一个新表中

/*
一般插入语句都是

insert into 表 () values ()

特殊需要就要用这种方法了

insert into 表1 () select ....from 表2
复杂一点的,比如涉及到2个以上的表:

insert into 表名1(字段1,字段2,字段3,字段4)

select 'aa' as 字段1,'bb' as 字段2,'cc' as 字段3 ,(select 字段4 from 表2 where 条件);

有insert select 和insert values 没有insert values (select )
 
原文链接:https://blog.csdn.net/lsk_jd/article/details/6093422

https://blog.csdn.net/u012021123/article/details/77936314



*/

--房东表
create table fangdong(
ID int null,
Fname varchar(5000),
sex varchar(1000),
moneytime datetime null, --交租日期 
);
go

select * from fangdong
alter table fangdong add zuname varchar(1000);
alter table fangdong add moneymany int null;--交租金额 来源租金表
--增加列 
alter table fangdong add moneydemo decimal(18,2); --加入小数点显示 18,2 就是显示0后面的2个0,如果4个0,就写 18,4 就可以了 



--learn and write 案例1 把租金表里面的租金,替换到房东表里面的交租日期里面去。 
insert into fangdong(moneytime) se

猜你喜欢

转载自blog.csdn.net/chenggong9527/article/details/124061588
今日推荐