--创建表 for Eric
create table test
(
ID int not null identity(1,1) primary key,--identity(初始值,增长值) primary key 设置主键
name varchar(50) not null,
address varchar(50) not null
)
select * from test
--更新表中字段 for Eric
alter table test add tel int -- 添加一个tel字段
select * from test
sp_rename 'test.tel','telphone' --注意: 更改对象名的任一部分都可能会破坏脚本和存储过程。
select * from test
alter table test alter column telphone varchar(50) not null --更新字段类型
select * from test
alter table test drop column telphone --删除telphone字段
select * from test
--删除表 for Eric
delete from test where 条件 --根据条件删除表中对应的数据
truncate table test -- 不能在后面跟条件,相当于格式化此表.
drop table test --删除表(包括字段,结构。)