2)带条件的数据更新 update tablea a set a.price = 2.00 where a.id=‘02’
3)两张表关联更新为固定值 update tablea a set a.price =3.00 where exits(select 1 from tableb b where a.id=b.id) 将a,b相同id的 a表的price 字段更新为 3.00
4)关联更新数据来源第二张表 update tablea a set a.price=(select price from tablec c ) where exits (select 1 from tablec c where a.id=c.id) 将a表price字段 更新为 id和c表id相同的数据
5)关联更新多个字段 update tablea a set ( a.price,a.type)=(select c.price,c.type from tablec c ) where exits (select 1 from tablec c where a.id=c.id) 更新a表的price 和 type 字段
6)使用视图方式更新 update (select a.price old,c.price as new from tablea a ,tablec c where a.id=c.id) set old=new
示例 merge into tablea a ----要更新或者操作的表 using tablec c ----源表 using (select * from tablec ) c on a.id=c.id --匹配条件 when matched then set a.price=c.price --当匹配时进行更新操作 when not matched then --不匹配进行插入操作 insert values values(c.id,c.price)
查询所有数据的总记录数量 SELECT COUNT(1) FROM person; SELECT COUNT(*) FROM person;
带多个条件的查询 select id,name,sex,birthday from person WHERE name= ’张三’ AND sex= ’男’;
带多个条件的查询按顺序排序 select id,name,sex,birthday from person WHERE name= ’张三’ AND sex= ’男’ order by birthday ;
**
Oracle表的基本操作
** –创建表 create table userinfo ( id number(6,0), usernam varchar2(20), userpwd varchar2(20), email varchar2(30), regdate date );
添加一个字段remark字段,是varchar2类型,长度为100 alter table userinfo add remarks varchar2(100);
给字段添加注释 comment on column new_uesrinfo.remarks is ‘注释’;
–给字段改名 alter table table_name rename column column_name To new_column_name;
–修改表的名字 rename table_name to new_table_name;
删除字段 alter table table_name drop column column_name;
修改remarks字段修改字段的长度
alter table userinfo modify remarks varchar2(150);
–删除表数据 truncate table table_name;
delete from table_name
–删除表的结构 drop table table_name;
存储过程
create or replace procedure delete_emp (id scott.emp.empno%type) is begin delete from scott.emp where empno=id; exception when others then dbms_output.put_line(‘errors’); end;
存储函数
–查询某个员工的年收入 create or replace function Fupmoney(tname in varchar2) return number as –定义月薪参数 tmoney test_procedure.money%type; begin –得到月薪 select t.money into tmoney from test_procedure t where t.name = tname;
declare v_empno emp.empno%type; v_ename emp.ename%type; v_salary emp.sal%type; cursor emp_cursor is select empno,ename,sal from emp where deptno = 20; begin open emp_cursor; loop fetch emp_cursor into v_empno,v_ename,v_salary; exit when emp_cursor%notfound; dbms_output.put_line(‘编号为’||v_empno||‘的员工名字为’||v_ename ||’,他的薪资为’ ||v_salary); end loop; close emp_cursor; end;
--分组取最大最小常用sql--测试环境if OBJECT_ID('tb') is not null drop table tb;gocreate table tb( col1 int, col2 int, Fcount int)insert into tbselect 11,20,1 union allselect 11,22,1 union allselect 1
一、函数的使用
1.1、定义函数变量
var vName = funcation(params){
}
1.2、函数的调用
函数变量的调用: vName(params);
函数定义时自发调用:(function(params){})(params);
1.3、函数中变量赋值
var a = 'a';
var ff
Mac mini 型号: MC270CH-A RMB:5,688
Apple 对windows的产品支持不好,有以下问题:
1.装完了xp,发现机身很热虽然没有运行任何程序!貌似显卡跑游戏发热一样,按照那样的发热量,那部机子损耗很大,使用寿命受到严重的影响!
2.反观安装了Mac os的展示机,发热量很小,运行了1天温度也没有那么高
&nbs
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Write a function to determine if a given ta