–Update 语句基本 语 法:
update 表名 set 列名= = 表达式 [, 列名 2= 表达式 2,...][where 条件 ]
BOOKID BOOKNAME BOOKAUTHOR BOOKTYPE BOOKPRICE
---------- -----------------------------
1 c fa eee 4.30
2 c++ zheng
修改bookid为1的记录的bookname为‘ORACLE’ ;
update books set bookname='Oracle' where bookid=1;
–基本语法:删除语句
delete from TABLENAME [where where_definition];
delete from 表名 [where 条件表达式 ];
--注意事项:
-- 1、如果不使用 where 子句,将删除表中所有的数据。(特别注意)
-- 2、delete 语句不能删除某一列的值(可使用 update)。
-- 3、使用 delete 语句仅删除记录,不删除表本身。如要删除表,使用 drop table 语句。
-- 4、同 insert 和 update 一样,从一个表中删除记录将引起其它表的参照完整性问题,在修改数据库数据时,头脑中应始终不要忘记这个潜在的问题。
delete from books where bookauthor='zheng';
–savepoint 保存点名称;
回滚
–rollback to 保存点名称;
--特别注意:设置保存点及回滚操作是配合 delete 语句使用,用来找回使用 delete删除的数据。
-- 而通过truncate删除的表数据是无法通过此方法找回的。
– 简单的查询语句
1 ) 查询所有列
SQL>select * from 表名;
2 ) 查询指定列
SQL>select 列 1,列 2,列 3,.. from 表名;
3 ) 如何取消重复行
SQL>select distinct deptno,job from emp;
4)查询 SMITH 的薪水,工作,所在部门
SQL>select sal,job,deptno from emp where ename='SMITH';
– 特别注意:
oracle 对sql语句不区分大小写,但对查询内容区分大小写。这与 sqlserver 是有区别的,sqlserver对查询内容不区分大小写。
–使用算数表达式
1.显示每个雇员的年工资
select ename, sal*12 from emp;