易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL select

--desc 表名 描述表的内容  
desc emp;
--加上数学表达式和列名  ""保持格式
select ename "name space", sal*12 year_sal from emp;   
select 2*3 from dual;
select sysdate from dual;
--空值的数学表达式 结果都是空值
select ename, sal*12 + comm from emp;  
--"||"字符串连接 单引号中的是字符串,字符串中的单引号,''表示
select ename||sal from emp;    
--distinct 修饰两个字段
select distinct deptno, job from emp;
select ename, sal from emp where sal between 800 and 1500;
select ename, sal from emp where sal >= 800 and sal <= 1500;
select ename, sal from emp where comm is null;
--一个事务开始于一条ddl语句,结束语rollback commit ddl数据定义语句 dcl数据控制语句语句
--正常断开连接 提交 非正常断开连接 回滚
select ename, sal from emp where sal not in (800 ,1500);
-- 模糊查询
select ename, sal from emp where ename like '_A%';
select ename, sal from emp where ename like '%\%%';
--转义字符
select ename, sal from emp where ename like '%$%%' escape '$';
--排序
select * from dept order by deptno desc;
select ename, sal from emp order by deptno asc, ename desc;
--函数
select lower(ename) from emp;
select substr(ename,1,3) from emp;
select round(23.652, 1) from dual;
select to_char(sal, '$99,999.999') from emp;
select to_char(sal, 'L000,000.000') from emp;
select to_char(hiredate, 'yyyy-mm-dd hh:mi:ss') from emp;
select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') from dual;
select ename, hiredate from emp
    where hiredate > to_date('1982-09-11 12:44:44', 'YYYY-MM-DD HH24:MI:SS');
select sal from emp where sal > to_number('$1,250.000', '$9,999.000');
select ename,sal*12 + nvl(comm, 0) from emp;
--组函数  多行输入,只有一行输出 select ename, max(sal) from emp; 结果不能保证只有一行
select max(sal) from emp;
select sum(sal) from emp;
select count(distinct deptno) from emp;
--分组函数
select deptno,avg(sal) from emp group by deptno;
select deptno, job, max(sal


相关文档:

Access和SQL2000中语句的区别

1 ,对于日期字段字段
access表示为:#1981-28-12#
SQLSERVER2000表示为:''1981-02-12''
2,SQL语句区别,select ,update 在对单表操作时都差不多,
但多表操作时update语句的区别ACCESS与SQLSERVER中的Update语句对比:
SQLSERVER中更新多表的Update语句:
Update Tab1
SET a.Name = b.Name
from Tab1 a,Tab2 b
Whe ......

JSP防SQL注入攻击

第一种采用预编译语句集,它内置了处理SQL注入的能力,只要使用它的setString方法传值即可:
String sql= "select * from users where username=? and password=?;
PreparedStatement preState = conn.prepareStatement(sql);
preState.setString(1, userName);
preState.setString(2, password);
ResultSet rs = ......

oracle sql优化之多表连接优化


Use equality first.
使用等连接
Use range operators only where equality does not apply.
只有在等连接不可用的情况下事由区间连接
Avoid use of negatives in the form of !=
or NOT.
避免使用 != 或者 not
Avoid LIKE pattern matching.
避免使用 LIKE匹配
Try to retrieve specific rows and in small n ......

Oracle开发之SQL语句案例—分析函数的使用

创建雇员表:
create table emp(deptno number(10),ename varchar2(100),sal number(10,2));
插入数据
begin
insert into emp values('10','KING',5000);
insert into emp values('10','CLARK',2450);
insert into emp values('10','MILLER',1300);
insert into emp values('20','SCOTT',3000);
insert into emp v ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号