T-SQL_4 增删改查语句
2010-02-01 22:33
169 查看
数据库四种基本操作:
1, "增" 插入语句
2, "删" 删除语句
3, "改" 修改语句
4, "查" 查询语句
1, "增" 插入语句
/*插入语句*/ use MyTestsDB go --1, 添加标识列 if exists(select name from sysobjects where name = 'newTable') drop table newTable select pID, pName, identity(int, 1, 1) as pNo into newTable from TB_person go --2, 插入一条记录 insert into TB_person(pID, pName) values(610322198602239777,'达熊') insert into TB_stuInfo(stuNO, stuName, stuAge, stuID) values(2009106801, '宁波', 16, 610322198602239777) --3, 插入多条记录 insert into TB_person select 610322198602239775,'GOF' union select 610322198602239771,'Lee' union select 610322198602239773,'小马哥'
2, "删" 删除语句
use MyTestsDB go /*删除数据*/ --已被引用过的数据行,删除时触发REFERENCE约束冲突 --delete from TB_person --where pID = 610322198602239777 delete from TB_person where pID = 610322198602239775 /*清空表*/ Truncate table TB_stuInfo
3, "改" 修改语句
/*修改语句*/ update TB_stuInfo set stuAge = 18 where stuAge < 18
4, "查" 查询语句
select stuName as 学生姓名, 学生年龄 = stuAge, stuAddress as 学生住址 from TB_stuInfo where stuAge > 18 group by stuAge having COUNT(stuAge)>1
相关文章推荐
- SQL常用增删改查语句,留着以后用
- 关于mybatis增删改查时条件为一个集合时如何利用foreach书写sql语句
- 数据库的增删改查crud(sql语句)
- 二、SQL语句映射文件(2)增删改查、参数、缓存
- SQL语句之增删查改、多表查询,模糊查询
- SQL语句的增删改查
- SQL增删改查语句格式参考二
- SQL语句增删改查
- 执行SQL语句的增删改查
- MyBatis之SQL语句映射文件增删改查和Java参数如何对应
- easyui datagrid 禁止选中行 EF的增删改查(转载) C# 获取用户IP地址(转载) MVC EF 执行SQL语句(转载) 在EF中执行SQL语句(转载) EF中使用SQL语句或存储过程 .net MVC使用Session验证用户登录 PowerDesigner 参照完整性约束(转载)
- SQL相关增删改查语句
- 数据库SQL语句的增删改查(总结)
- MyBatis学习 之 二、SQL语句映射文件(2)增删改查、参数、缓存
- MyBatis学习 之 二、SQL语句映射文件(2)增删改查、参数、缓存
- sql常用语句整理(包括增删改查)
- 常用SQL语句(增删查改、合并统计、模糊搜索)
- 二、SQL语句映射文件(2)增删改查、参数、缓存
- 二、SQL语句映射文件(2)增删改查、参数、缓存
- MyBatis学习 之 二、SQL语句映射文件(2)增删改查、参数、缓存