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

oracle中的常用sql语句(7)

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

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


to_date(字符串,格式) --将字符串按照指定的格式转换成date数据类型

--4.4 基本查询
--4.4.1 select语句
select 列1,列2,...,列n from 表 where 条件 order by 列
select user_id,user_name,user_pass,user_birthday,user_nickname from bbs_user;
select * from bbs_user; --效率低

--4.4.2 基本查询
--4.4.2.1 包含算数表达式(number、null、date)
select user_id,user_name,user_pass,user_birthday,user_birthday+10
from bbs_user;

select user_id *0.25 + 100 ,user_id,user_pass,user_name
from bbs_user;

select topic_id,topic_title,topic_user_id,
(topic_user_id + 100)/2.5*0.35,
(topic_last_reply_user_id + 100)*3.5/0.34
from bbs_topic;

--4.4.2.2 包含连接表达式
select topic_id,topic_title,topic_title || '-->这里是测试数据'
from bbs_topic;

select topic_id,topic_title,topic_title || '-->这里是测试数据' || '-->系统时间:' || to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')
from bbs_topic;

--4.4.2.3 空值的使用
--在null值身上进行任何操作得到结果均为null

--4.4.2.4 字段别名、表别名
select * from bbs_user;

select user_id as 编号,user_name as 登录名,user_pass as 密码,user_nickname as 昵称
from bbs_user;

select user_id as "my name",user_name as "我的 登录名",user_pass as 密码,user_nickname as 昵称
from bbs_user;

select er_id as 编号, er_name as 登录名
from bbs_user u;

--4.4.2.5 文本字符串
select user_id as 编号, '你爷爷' as 姓名
from bbs_user;

--4.4.2.6 去掉重复值
select * from bbs_user_section;

select distinct us_user_id from bbs_user_section;

--4.4.3 带有限制条件的查询
--4.4.3.1 where语句
语法:
select 列1,列2,...,列n
from 表
where 条件

--4.4.3.2 where中的比较操作符
> < >= <= <> =
select * from bbs_user;
select * from bbs_user where user_gender = '男';
select * from bbs_user where user_gender <> '男';

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

select * from bbs_topic;
select * from bbs_reply;

--4.4.3.3 where中的逻辑运算符
and or not

select * from bbs_user
where us
er_gender <> '男' and user_birthday> to_date('1989-12-31','yyyy-mm-dd');

like -- 通配符 %(任意长度的任意字符) _(一个长度的任意字符)
select * from bbs_use

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

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

相关推荐:

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