SQL Server2000 增删改查语句

给我4个例子增删改查 就可以
谢谢大侠们 最好加注释 因为SQL我不太会

增加记录:insert into 表名(列1,列2,列3) values(值1,值2,值3);
删除表里所有内容:delete from 表名
根据ID值删除记录:delete from 表名 where ID=值
修改记录:update 表名 set 列1=值1,列2=值2,列3=值3 where ID=值
查询记录:select * from 表名
根据ID值查询内容:select * from 表名 where ID=值
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-01-31
create table TS1
(
Id int identity(1,1) primary key,
Name varchar(30) Unique,--不允许重复,但是可以为空一次,因为为空两次就重复了,可以用Not null来控制不为空!
Age tinyint,
Note_Time smalldatetime,
)

create default mydef1 as getdate()
--建立一个默认值,删掉请使用:drop default mydef1,默认值为当前时间

Sp_bindefault mydef1,'TS1.Note_Time'--邦定默认值,第一个参数是默认值的名字,第二个就是表的字段(表.字段)
Go

create rule myrule1 as @Age>=0 and @Age<=120
--建立一个规则,规则是如果邦定到一个字段,那么那个字段的值必须在0和120之间
Go
Sp_bindrule myrule1,'TS1.Age'
--邦定规则,第一个参数是规则的名字,第二个就是表的字段(表.字段)

--这个时候表建立成功,我是为了演示就帮你写的这个麻烦,等你学好sql后,你就知道了(我不是申明我学好了SQL)

insert into ts1 (name) values ('a')
--insert into ts1 (name,age) values ('b',130),错误违反我定义的规则
insert into ts1 (name,age) values ('b',30)
insert into ts1 values ('c',10,'2000-01-01')

--插入完成

--查询:

select * from ts1

select * from ts1 where id=1

select * from ts1 where name='b'

--更新

update ts1 set name='abc' where name='a'

--删除

delete ts1 where id=1

--测试OK
第2个回答  2008-01-31
1:增加语句
insert into 表名(字段1,字段2……)values(值1,值2)
如果没有填写字段,默认为表中的每个列增加一个值
2:删除语句
delete from 表名 where(条件)
3:修改语句
update 表名 set 字段1=值1,字段2=值2,……where (条件)
4:查询语句
selete 字段1,字段2(或者 *)from 表名 where (条件)
如果是 * 默认为查询整张表的数据
第3个回答  2008-01-31
--查询
select 字段或* from 表名 where 限制条件
select * from table where id>2000

--增加
insert into 表名(字段) values (值)
insert into table1(name,description) values ('aaa','bbb')

--修改
update 表名 set 字段=值 where 限制条件
update table1 set name='ccc' where id=1

--删除
delete 表名 where 限制条件
delete table1 where id=1
相似回答