Oracle笔记 四、增删改、事务

 

 
1、插入
    insert into
 dept values
(50, 'soft'
, 'Guangzhou'
);
    insert into
 dept(deptno, dname) values
(60, 'software test'
);
    insert into
 dept select
 * from
 dept where
 deptno = 20;
 
2、删除
    delete
 from
 dept where
 deptno = 20;
    delete
 from
 dept;
 
3、修改
    update
 dept set
 dname = dname || ' ^.^'
 where
 deptno = 20;
 
4、事务
    每个修改语句完成后都可以回滚或提交,即rollback、commit
    eg:
    insert into
 dept values
(50, 'soft'
, 'Guangzhou'
);
    rollback
;
    这样就回滚了,等于上面的没有插入;如果commit就提交了,此后如果再rollback也无力回天了。
    下面这样也是无法回滚的:
    insert into
 dept values
(50, 'soft'
, 'Guangzhou'
);
    create
 table
 temp as
 select
 * from
 dept;
    rollback
;
    再次查询,发现无法回滚;同样增删改后面运行grant/create语句也是无法回滚的;

你可能感兴趣的:(oracle,table,delete,insert)