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)) ;
缺省选项: hiredate DATE DEFAULT SYSDATE
创建一个和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;
ALTER TABLE命令 增加一列或更改一个现有列类型
eg : 增加一列
ALTER TABLE dept
ADD (id number(2));
eg: 更改一列
ALTER TABLE dept
MODIFY (ename varchar2(15));
eg: 删除一列
ALTER TABLE
DROP COLUMN job;
丢弃一个表: DROP TABLE dept;
更改一个表的名称: RENAME dept TO department;
截断一个表:truncate table department;
truncate 截断表 移除表中数据,释放存储空间 不可回退
drop 删除表 移除表中数据 ,可回退
COMMENT ON TABLE emp
IS ‘Employee Information‘;