`

收集的一些SQL(更新中)

阅读更多
sql语句的条件查询有:in,like,beteen...and,is null,is not null等,在条件中还可以包含select子查询。
sql比较查询运算符有:= ,>,<>,<,!=,<>,>=,<=,!>,!<;一般有数字比效,字符串比较,日期比效。
sql逻辑运算符共有3种:and,or,not
sql谓词in查询:例
select * from 定单 where zhigong (not) in('a','b','c','d')
sql模糊like查询:
例1 select * from zhigong where xingming not like '王%'
例2 select * from zhigong where xingming not like '王_'
sql空值查询: 例 select * from zhigong where xingbie is null
例2 select * from zhigong where xingbie is not null
sql限制范围查询:between...and 例 select * from zhigong where gongzi between 1300 and 1900
sql消除重复字段数据distinct查询 例 select distinct gongzi from zhigong
sql单表嵌套查询 select * from canghu where mianji>(select mianji from cangku where cangkuhao='wh')
sql多表嵌套查询
例1 select * from zhigong where cangkuhao in (select cangkuhao from cangku where chengshi='北京')
例2 select * from dingdan where zhigonghao in(select zhigonghao from zhigong where cangkuhao in ( select cangkuhao from cangku where chengshi='beijing'))
例3 select * from dingdan where zhigonghao in(select zhigonghao from zhigong where gongzi>1200 and cangkuhao in(select cangkuhao from cangku where chengshi='北京'))and 订购日期 between '2003-09-03'and '2006-01-01'
例4 select * from zhigong where zhigonghao in(select zhigonghao from dinggoudan)
例5 select * from zhigong where cangkuhao in(select cangkuhao from cangku where chengshi is not null) and gongzi between 1300 and 2100 and zhigonghao in (select zhigonghao from dinggoudan where jine not between 8000 and 12000)
例6 select * from zhigong where gongzi between(select gongzi from zhigong where zhigonghao='ad') and (select gongzi from zhigong where zhigonghao='df') and cangkuhao in (select cangkuhao from cangku where chengshi='beijin')
分组查询 分组查询关键词是group by 分组之前的关键词要用where 分组这后要用having
例 select cangkuhao,max(gongzi) as zuodagongai,min(gongzi)as zuixiaogongzi sum(gongzi) as gongzizonghe,avg(gongzi) as pinjungongzi,count(*)as zhigongrenshu from zhigong where gongzi>(select gongzi from zhigong where zhigonghao='aa') group by cangkuhao having avg(gongzi)>1760
*/

快速清空表内容:
例 truncate table xxxx     \    truncate table user.xxxx     注:user为数据库的用户,就是清空user用户的xxxx表内容。

复制一个表中的数据到另外一个表:
例 create table yyy as select * from uuu。即把uuu表中的数据复制到yyy中。

同样可以复制到同服务器上的oracle中的其他用户里(用user为例):
create table user.yyy as select * from uuu
分享到:
评论

相关推荐

    sql 教程和经典sql

    收集了一些,比较实用的sql语句和教程,SQL参考手册;行列转换等

    SQL掌用实例大收集

    SQL掌用实例大收集包括了一些经常用到的sql操作

    SQLServer2005数据库学习笔记

    笔记是本人学习SQLServer一段时间后重新整理出来的,适合有一些入门基础的人学习。 ├─01 安装及使用 │ SQLServer2005安装及使用.txt │ ├─02 常用函数 │ function.sql │ ├─03 建表、建库 │ create.sql ...

    SQL语句收集(实用版)

    精妙 SQL 语句 收集 全集 sql 可以做为查询用。

    达梦数据库并行收集统计信息.sql

    达梦数据库并行收集统计信息.sql

    SQL语法格式(更新中)[收集].pdf

    SQL语法格式(更新中)[收集].pdf

    精妙SQL语句收集 常用SQL语法解析

    收集常用SQL语句。常用SQL语法解析,

    Oracle 高性能SQL引擎剖析:SQL优化与调优机制详解 (黄玮) 高清PDF扫描版

    用大量示例详尽分析oracle 中现有的各种查询转换技术,先分析oracle如何收集、统计系统和对象的数据,然后推导各种代价估算公式,给出各种情形下的代价计算演示。 第三篇“sql调优技术”深入剖析oracle提供的各项...

    收获不止SQL优化

    第1章 全局在胸——用工具对SQL整体优化 1 1.1 都有哪些性能工具 1 1.1.1 不同调优场景分析 2 1.1.2 不同场景对应工具 2 1.2 整体性能工具的要点 4 1.2.1 五大性能报告的获取 5 1.2.2 五大报告关注的要点 10 ...

    sql技术收集8

    sql技术收集8sql技术收集8sql技术收集8sql技术收集8

    sql sever 2008

     SQL Server 2008 SP3 包含 SQL Server 2008 SP2 累积更新包 1 至 4 的累积更新,以及对通过客户反馈平台所收集问题的修复。它包括可支持性增强以及通过 Windows 错误报告收集的问题。  支持的操作系统:Windows 7...

    SQL Server 2008的性能数据收集器

    SQL Server 2008的性能数据收集器

    C#防SQL注入代码的三种方法

    对于网站的安全性,是每个网站开发者和运营者最关心的问题。网站一旦出现漏洞,那势必将造成很大的损失。为了提高网站的安全性,首先网站要防注入,最重要的是服务器的安全设施要做到位。... 在Web.config文件中

    SQLSERVER语句收集

    SQLSERVER语句收集SQLSERVER语句收集SQLSERVER语句收集SQLSERVER语句收集SQLSERVER语句收集SQLSERVER语句收集SQLSERVER语句收集SQLSERVER语句收集SQLSERVER语句收集SQLSERVER语句收集

    sql99.rar_SQL99 chm_sql_sql 99_sql99_sql99文档下载

    网上搜集的sql的一些文档,主要将一些sql99标准

    sqlserver常用一些技巧

    疑难SQL语句合集,精妙SQL语句收集,精典的SQL语句,超难的Sql查询(纵向转横向+分组统计).从简单到困难。欢迎交流。

    HIVE-SQL开发规范.docx

    hive是基于Hadoop的一个数据仓库工具,用来进行数据提取、转化、加载,这是一种可以存储、查询和分析存储在Hadoop中的...本文是Hive的开发规范,包括从网上搜集的一些内容,也包括在工作中总结的,以及在书中整理的点。

    SQL Csdn收集

    SQL Csdn收集. SQL Csdn收集.

    sql技术收集

    sql技术收集sql技术收集sql技术收集

Global site tag (gtag.js) - Google Analytics