发文章
发文工具
撰写
网文摘手
文档
视频
思维导图
随笔
相册
原创同步助手
其他工具
图片转文字
文件清理
AI助手
留言交流
--1.使用事务定义与提交命令在数据库studentcourse中创建一个 --“综合表”(学号,姓名,性别,民族),并为它插入3行数据,观察 --提交之前和之后的浏览与回滚情况。 create table zonghe( sno varchar(10) primary key,sname varchar(10), ssex char(2),sjg char(10)) select @@TRANCOUNT as trancount go begin transaction addzonghe insert into zonghe(sno,sname,ssex,sjg) values('Q0403','陈力','男','汉族') insert into zonghe(sno,sname,ssex,sjg) values('Q0401','高手','男','汉族') insert into zonghe(sno,sname,ssex,sjg) values('Q0402','刘备','男','汉族') go select @@TRANCOUNT as tancount if @@ERROR<>0 rollback tran select @@TRANCOUNT as trancount go commit tran addzongfen 2. 定义事务,在学生选课数据库studentcourse的学生选 课数据表SC中,为所有成绩高于50分的同学的成绩增加10分。 begin transaction addfenshu go update SC set sc.成绩=SC.成绩+50 from SC where SC.成绩>50 commit transaction addzongfen 3. 定义一个事务,向学生选课数据表SC中插入一行数据(S0408 C01 46), 然后删除该行。执行结果是此行没有加入。要求在删除命令前定义保存点MY, 并使用ROLLBACK语句将操作滚回到保存点,即删除前的状态.观察 全局变量@@TRANCOUNT的值的变化。 begin tran use studentcourse insert into SC values('S0408','C01',46) save tran MY delete from SC where sc.学号='S0408' rollback tran my commit tran
来自: 昵称10504424 > 《工作》
0条评论
发表
请遵守用户 评论公约
sql查询语句select 应用举例
select sname from student where sdept=''cs''select sname,ssex from student where sdept=''is'' or sdept=''ma'' or sdept=''cs'...
mysql视图的作用
视图是从一个或几个基本表(或视图)导出的表。它与基本表不同,是一个虚表。
实验四:查询语句练习
select sdept,sname,sagefrom studentwhere sdept=‘计算机’select sname,sagefrom studentwhere sage<18.select sname,sage from studentwhere sage>20.select sname,sagefrom studentwhere ...
Sql面试宝典带答案
INSERTINTO S1(Sno,SNAME,SSEX) SELECT Sno,SNAME,SSEX FROM S WHERE NOT EXISTS(SELECT * FROM SC WHERE GRADE<80 AND S.Sno=SC.Sno or S.Sno=SC.Sno and gradeis null) and sno in (select sno fr...
通过16道练习学习Linq和Lambda
Cno from student as s,course as c ,score as sc where s.sno=(select sno from score where degree = (select max(degree) from score))and c.cno = (select cno from score where degree = (select ...
实验记录
select student.sno,sname,sc.cno,gradefrom student,course,scwhere student.sno=sc.sno and course.cno=sc.cno;create table sc1 ( sno char (9), cno char (9), ...
SQL-基于派生表的查询
Select Sno,CnoFrom SC XWhere Grade>(Select AVG(Grade) From SC Y Where Y.Sno=X.Sno);SELECT Sno,Cno FROM SC,(SELECT Sno,Avg(Grade) FROM SC GROUP BY Sno) AS Avg_sc(avg_sno,avg_grade)WHE...
数据库
select cno from course where cname = ''''''''计算机导论''''''''; #根据课程表找到课程编号 select sno from score where cno = ...
经典SQL练习题
SELECT A.SNO,A.DEGREE FROM SCORE A JOIN (TEACHER B,COURSE C)ON A.CNO=C.CNO AND B.TNO=C.TNOWHERE B.TNAME=''张旭'';另一种解法:select cno,sno,degree from score where cno=(se...
微信扫码,在手机上查看选中内容