Oracle_insert_delete_update
--复制表格的结构 create table temp as (select * from emp where 1=2); select * from temp; --删除表 drop table temp; |
插入 |
--1.插入 新增 insert into temp(empno, ename, job, hiredate, sal) values(1234, ‘test张三‘, ‘programer‘, sysdate, 12000 ); insert into temp(empno, ename, job, hiredate, sal) values(1234, ‘张小夫老三‘, ‘programer‘, sysdate, 12000 ); insert into temp(empno, ename, job, hiredate, sal) values(1234, ‘张老三‘, ‘programer‘, sysdate, 12000.9098 ); insert into temp values(1111, ‘张sdf‘, ‘student‘, ‘1233‘,to_date(‘2010-5-12‘,‘yyyy-mm-dd‘), 2000,12000.9098,10); --1.2一次性插入多条记录 insert into temp(select * from emp); select * from temp; |
删除 |
--2.删除表中的数据 delete from temp; delete from temp where empno=7369; --2.2彻底删除表中的所有数据,不可回滚 truncate table temp; |
更新 |
--3.更新 --将30部门所有员工的薪水提升10% update temp set sal=sal + sal*2 where deptno = 30; select deptno, sal from emp where deptno = 30; select deptno, sal from temp where deptno = 30; update temp set ename=‘test‘, sal=8000 where empno=7369; select * from emp where empno=7369; select * from temp where empno=7369; |