日期:2014-05-18 浏览次数:20556 次
--转存为table2 select id, 名字, 0 '年龄', 地址, 电话 into table2 from table1 --删除table1 drop table table1 --重命名为table1 sp_rename 'table2','table1'
------解决方案--------------------
alter table tabel1 add [年龄] int not null
------解决方案--------------------
if OBJECT_ID('tb') is not null
drop table tb
go
create table tb (id int,名字 varchar(50),地址 varchar(50),电话 varchar(50))
select * from tb
--现在想在“地址”前加个字段“年龄” 类型为int ,not null
alter table tb add 年龄 int NOT NULL
select * from tb
id 名字 地址 电话
----------- -------------------------------------------------- -------------------------------------------------- --------------------------------------------------
(0 行受影响)
id 名字 地址 电话 年龄
----------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -----------
(0 行受影响