事物 :
一:编程事物
1:完整性
① 显示
② 隐式
2:部分事物,完整,完成
3:只读事物(影响他人)
4:独立事物(sqlservet)
5:孤独事物(sqlservet)
二:声明式事物:
布置 xml 71spring java里
------------------------------------------------1.实体完整性----------------------------------------
例1
INSERT INTO Students (name,specialty)
VALUES('王一','计算机');
例2
UPDATE Students SET student_id = NULL WHERE student_id = 10205;
例7.1_17
INSERT INTO Students
VALUES(10205, NULL,'张三', '男', '26-12月-1989','自动化');
例3
UPDATE Students
SET student_id = 10207
WHERE student_id = 10205;
------------------------------------------------参照完整性---------------------------------------
例1
DELETE FROM Departments WHERE department_id = 101;
例2
UPDATE Departments SET department_id = 105
WHERE department_id = 102;
例3
INSERT INTO Teachers
VALUES(10805,'李四', '教授', '01-9月-1990',1000,3000,108);
例4
UPDATE Teachers SET department_id = 107
WHERE teacher_id = 10106;
-----------------------------------------------自定义完整性---------------------------------------
例1
INSERT INTO Students (student_id,dob,sex,specialty)
VALUES(10178,'20-12月-1989','男','计算机');
例2
UPDATE Students SET sex='南'
WHERE student_id = 10205;
CREATE TABLE Students_computer (
student_id NUMBER(5)
CONSTRAINT student_computer_pk PRIMARY KEY,
monitor_id NUMBER(5),
name VARCHAR2(10) NOT NULL,
sex VARCHAR2(6),
dob DATE,
specialty VARCHAR2(10)
);
例3
INSERT INTO Students_computer
(SELECT * FROM Students WHERE specialty = '计算机');
例4
UPDATE Teachers SET bonus =
(SELECT AVG(bonus) FROM Teachers)
WHERE bonus IS NULL;
例5
DELETE FROM Teachers
WHERE wage >
(SELECT 1.1*AVG(wage) FROM Teachers);
----------------------------数据事物----------------------------------
--1显示事物
INSERT INTO departments VALUES(111,"地球物理","X号教学楼");
COMMIT;
SELECT * FROM departments;
---2:全部取消事物
update departments set address='5号教学楼' where department_id=104;
select * from departments;
rollback;
select * from departments;
---3:部分取消
update departments set address='5号教学楼'
where department_id=104;
savepoint spl;
delete from departments where department_id=104;
select * from departments;
rollback to spl;
select * from departments;
------------------------------特殊事物------------------
----1:只读事物
set transactton read only;
select * from departments;
update departments set address='8号教学楼'
where department_id=104;
rollback;
------------------------------顺序事物-----------------------
set transactton isolatton level serlalizable;
.