操作数据----DML语句

insert语句基本语法

 insert into table(column) values(values);

insert into dept
(deptno,dname,loc)
 values(50,'development','detroit');                            //当所有列都要插入数值时可不写第二行,直接按照顺序写第三行

update语句

update dept set deptno=11 where loc='zjk';

delete语句

delete (from) dept where deptno=11;

commit 提交

ROLLBACK 回滚

savepoint 使用savepoint语句在当前事务中产生一个标记,使用rollback to 回滚到那个标记

savepoint a;            

rollback to a;

从一个表中拷贝一行:

insert into t_emp(empno,ename,sal,hiredate)                                         不用写values,列与列之间应对应

             select empno,ename,sal,hiredate from emp where job='MANAGER';

 

创建和管理表:

create table emp
(id number(2),name varchar2(11),sal number(5)) ;

创建一个和emp一样的表

create table emp1 as 
select * from emp;

创建表,并将emp表按工资分成三个表

create table t_smallsal as 
select ename, empno, sal from emp where 1=2;

create table t_middlelsal as 
select ename, empno, sal from emp where 1=2;

create table t_largesal as 
select ename, empno, sal from emp where 1=2;

insert all
when sal < 1200 then
into t_smallsal
when sal >=1200 and sal < 3000 then
into t_middlesal
else 
into t_largesal 
select ename, empno, sal 
from emp;
update t_employee t
    set t.sal = (select t1.sal from emp t1    
             where t1.empno = t.empno
             and t.sal != t1.sal)                                            利用子查询更新数据
    where t.deptno = 20;

 truncate  截断表     移除表中数据,释放存储空间   不可回退

 truncate table emp;

 

posted @ 2015-03-22 14:00  qian@@jing  阅读(171)  评论(0编辑  收藏  举报