一些实用的sql语句
时间:2024-01-23 10:14:14
1.查询高于平均价格的商品名称:
SELECT item_name FROM ebsp.product_market_price WHERE item_price > (SELECT AVG(item_price) FROM ebsp.product_market_price
2.oracle9i以上版本,可以实现将某张表的数据同时插入到多张表中。例:
INSERT ALL
WHEN deptno=10 THEN INTO dept10 --部门编号为10的插入表dept10中
WHEN deptno=20 THEN INTO dept20
WHEN deptno=30 THEN INTO dept30
WHEN job='CLERK' THEN INTO clerk --岗位为CLERK的插入表clerk 中
ELSE INTO other
SELECT * FROM emp;
可以将前面的sql语句变为INSERT FIRST 后面不变,当使用First操作符执行多表插入时,如果数据已经满足了先前的条件,并且已经 * 入到某表中,那么该行数据在后续的插入中将不会被再次使用。
3.截取字符串制定的长度。
select substr(item_name,0,2) from ebsp.product_market_price
select substr(‘ho鲜红的鲜花 ',0,3) from dual; --print ‘ho鲜'
获得emp系统表中hiredate雇佣日期,有重复的记录,也就是一天中雇佣多名员工的记录。
SQL1: select * from scott.emp where hiredate in (select hiredate mycount from scott.emp group by hiredate having count(*) >1)
SQL2:select t2.* from scott.emp t2 ,
(select t.hiredate,count(*) mycount from scott.emp t group by t.hiredate having count(*) >1) t1
where t2.hiredate = t1.hiredate
如果hiredate存入数据库中时日期型带有时分秒,可以通过to_char(CREATE_DATE, 'YYYY-MM-DD')来代替上面的
4.修改oracle数据库缓存大小,以system登陆:
alter system set db_cache_size = 700m scope = spfile;
alter system set shared_pool_size = 200m scope=spfile;
alter system set pga_aggregate_target = 100m scope=spfile;
标签:sql语句
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python request post 列表的方法详解
2023-10-04 11:46:19
python获取txt文件词向量过程详解
2021-07-27 12:54:35
PyQt教程之自定义组件Switch Button的实现
2023-08-23 11:26:48
![](https://img.aspxhome.com/file/2023/4/112184_0s.webp)
简单介绍Python的Tornado框架中的协程异步实现原理
2021-06-21 10:00:23
Go语言实现钉钉发送通知
2024-05-08 10:44:29
Mootools 1.2教程(11)——Fx.Morph、Fx选项和Fx事件
2008-12-04 16:03:00
使用numpy对数组求平均时如何忽略nan值
2023-09-19 20:37:24
![](https://img.aspxhome.com/file/2023/7/97307_0s.png)
JavaScript实现图片自动加载的瀑布流效果
2024-06-05 09:13:43
![](https://img.aspxhome.com/file/2023/3/123373_0s.jpg)
讨论闭包传入参数:window & undefined
2010-05-19 12:55:00
python3中dict(字典)的使用方法示例
2022-06-14 11:44:39
Python matplotlib画图实例之绘制拥有彩条的图表
2023-01-26 02:06:25
![](https://img.aspxhome.com/file/2023/8/86268_0s.jpg)
Python将string转换到float的实例方法
2023-06-13 07:23:47
![](https://img.aspxhome.com/file/2023/5/59465_0s.png)
Flask-Vue前后端分离的全过程讲解
2022-08-07 23:51:11
MySQL 8.0.20 安装教程图文详解(windows 64位)
2024-01-22 07:32:07
![](https://img.aspxhome.com/file/2023/0/102360_0s.jpg)
跟我学习javascript的闭包
2024-04-23 09:11:51
![](https://img.aspxhome.com/file/2023/6/135676_0s.png)
JavaScript实现时钟滴答声效果
2024-04-16 10:38:19
![](https://img.aspxhome.com/file/2023/4/136574_0s.png)
python中的argparse基本用法(使用步骤)
2023-06-12 20:01:36
![](https://img.aspxhome.com/file/2023/1/59281_0s.png)
asp实现页面延迟运行的两个简单方法
2007-10-16 13:49:00
CentOS7使用yum安装Golang的超详细步骤
2024-04-30 10:08:01
![](https://img.aspxhome.com/file/2023/4/130684_0s.jpg)
Python爬虫逆向分析某云音乐加密参数的实例分析
2022-05-25 20:33:14
![](https://img.aspxhome.com/file/2023/8/101238_0s.png)