第一范文网 - 专业文章范例文档资料分享平台

oracle中的常用sql语句(8)

来源:用户分享 时间:2021-04-06 本文由逆光飞翔i 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

常用的sql语句,如建表、建索引、建约束条件;以及增删改查和高级查询操作

r
where user_name like '%A%'; --字符串大小写敏感

select * from bbs_user where user_name like '%a%' or user_name like '%A%';

select * from bbs_user where user_name not like '%a%';

select * from bbs_user where user_nickname like '_张%';

in -- 指定在某个范围之内
select * from bbs_user where user_gender in ('男','女');

select * from bbs_topic where topic_reply_count in (0,5);

select * from bbs_user where user_gender not in ('男','女');

--查询空值
select * from bbs_topic;

select * from bbs_topic where topic_last_reply_date is null;

select * from bbs_topic where topic_last_reply_date is not null;

--
select * from bbs_user
where user_birthday >= to_date('1985-01-01','yyyy-mm-dd')
and
user_birthday <= to_date('1989-12-31','yyyy-mm-dd');

select * from bbs_user
where user_birthday between to_date('1985-09-12 00:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('1989-03-28 23:59:59','yyyy-mm-dd hh24:mi:ss');
--4.4.4 给查询结果排序

语法:
select 列名
from 表
where 条件
order by 列 [ASC | DESC]

select * from bbs_topic order by topic_id desc;
select * from bbs_topic order by topic_date asc;

select * from bbs_topic
order by topic_date, topic_id; --按照topic_date排序,若有相同值则按照topic_id排序


---------------------------第五章 高级查询-----------------------------------
--5.1 函数查询
--5.1.1 单行函数
--5.1.1.1 字符函数
--5.1.1.2 数字函数
--5.1.1.3 日期函数
--5.1.1.4 转换函数
--5.1.1.5 其他函数
--5.1.2 分组函数
--5.1.2.1 常用分组函数
--5.1.2.2 使用group by对数据分组
--5.1.2.3 使用having对组结果进行限制
--5.2 多表连接查询
--5.2.1 多表链接分类
--5.2.2 等值连接
--5.2.3 非等值连接
--5.2.4 外连接
--5.2.5 自连接
--5.3 子查询
--5.3.1 子查询类型
--5.3.2 单行子查询
--5.3.3 多行子查询
--5.3.4 多列字查询



--5.1 函数查询
--5.1.1 单行函数
--5.1.1.1 字符函数

lower(char)
select lower('THIS IS A VERY NICE MORNING. hello') as 问好 from dual;
select lower('大家早上好,你们好吗?') as 问好 from dual;
upper(char)
select upper('i love this game. NBA.') from dual;
initcap(ch
ar)
select initcap('i love this game. NBA. 我爱这个游戏!') from dual;
select initcap('i love this game.') || 'NBA' from dual;
ascii(char

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新资格考试认证oracle中的常用sql语句(8)全文阅读和word下载服务。

oracle中的常用sql语句(8).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1185251.html(转载请注明文章来源)

相关推荐:

热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top