SQL 提交无效
SQL commit not working
我正在尝试使用回滚返回到上一个语句,我 commit.But 不是 working.It 总是显示当前语句。这意味着提交不起作用?我该如何解决?
drop table departments_dup;
create table departments_dup
(
dept_no char(4),
dept_name varchar(40)
);
insert into departments_dup
select * from departments;
SELECT
*
FROM
departments_dup
ORDER BY dept_no;
commit;
UPDATE departments_dup
SET
dept_name = 'Quality Control',
dept_no = 'd021';
ROLLBACK;
Mysql默认autocommit为true,所以你可以在语句前开启事务,commit到最后;
START TRANSACTION;
UPDATE departments_dup
SET
dept_name = 'Quality Control',
dept_no = 'd021';
ROLLBACK;
或者您可以将自动提交设置为 false,将以下内容添加到 my.cnf 文件的 [mysqld] 部分。
init_connect='set autocommit=0'
虽然这会为每个客户端设置自动提交关闭。
我正在尝试使用回滚返回到上一个语句,我 commit.But 不是 working.It 总是显示当前语句。这意味着提交不起作用?我该如何解决?
drop table departments_dup;
create table departments_dup
(
dept_no char(4),
dept_name varchar(40)
);
insert into departments_dup
select * from departments;
SELECT
*
FROM
departments_dup
ORDER BY dept_no;
commit;
UPDATE departments_dup
SET
dept_name = 'Quality Control',
dept_no = 'd021';
ROLLBACK;
Mysql默认autocommit为true,所以你可以在语句前开启事务,commit到最后;
START TRANSACTION;
UPDATE departments_dup
SET
dept_name = 'Quality Control',
dept_no = 'd021';
ROLLBACK;
或者您可以将自动提交设置为 false,将以下内容添加到 my.cnf 文件的 [mysqld] 部分。
init_connect='set autocommit=0'
虽然这会为每个客户端设置自动提交关闭。