Oracle操作语句

Oracle操作语句
建立表:
 创建一个简单的表
Create table test(
Name varchar2(16),
Age number(3), 
Birth date
);

insert 插入:
insert into emp
  values(8001,'java','clerk',7902,sysdate,1000,null,10);

update 修改:
update emp set ename='jack',job='clerk'(修改表中全部数据)
update emp set ename='jack',job='clerk'(修改指定记录)
  where empno=8000;

delete 删除:
delete from emp;(删除表中全部数据)
delete from emp wehre empno=8000;(删除指定记录)
delete from emp where empno>8000;
 
备份表
Merge语句
merge into emp_bak eb
 using(select * from emp) e
 on(eb.empno=e.empno)
   when matched then
   update set
          eb.ename=e.ename,eb.job=e.job;
   when not matched then
   insert(ename,job) balues(e.ename,e.job);
数据库的事物
COMMIT  提交
ROLLBACK 回滚
insert into emp(empno,ename) values(8002,'zhangsan');
insert into emp(empno,ename) values(8003,'zhangsan');
create table tt(ename varchar2(20));
insert into emp_bak(empno,ename) values(8002,'zhangsan');
rollback;
--emp表插入两条数据,emp_bak表没有插入数据
 
建立存储点
savepoint a;
回滚存储点
rollback to a;

你可能感兴趣的:(oracle,职场,休闲,创建表,操作语句)