同时对三张表进行插入操作,事务保证完整性。下面进行简单测试:
1. 锁定表
锁定用户表
查看表是否锁定:
显示被锁定的表。
2. 验证在同一session下是否可以插入操作
可以操作成功。
3. 启动spring应用,执行插入操作,不能成功。
4,解锁
查看被锁定的表:
上述表不在锁定中。
5. 调用spring应用,执行插入操作,操作可以成功。
所以,应用spring的@transactional进行事务管理是ok的。
附录:
Syntax:https://dev.MysqL.com/doc/refman/5.0/en/show-open-tables.html
db_name] [LIKE 'pattern' | WHERE expr]
lists the non-teral">TEMPORARY
tables that are currently open in the table cache. See. The clause can be given to select rows using more general conditions,as discussed in .
The teral">FROM
and clauses may be used as of MysqL 5.0.12. The clause,if present,indicates which table names to match. The teral">FROM
clause,restricts the tables shown to those present in the db_namedatabase.
output has the following columns:
teral">Database
The database containing the table.
teral">Table
The table name.
teral">In_use
The number of table locks or lock requests there are for the table. For example,if one client acquires a lock for a table using teral">LOCK TABLE t1 WRITE
, teral">In_use
will be 1. If another client issues teral">LOCK TABLE t1 WRITE
while the table remains locked,the client will block waiting for the lock,but the lock request causes teral">In_use
to be 2. If the count is zero,the table is open but not currently being used. teral">In_use
is also increased by the statement and decreased by .
teral">Name_locked
Whether the table name is locked. Name locking is used for operations such as dropping or renaming tables.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。