------------------------------------------------ Oracle 日期------------------------------------------ -- 本季度第一天 SELECT to_char(TRUNC(SYSDATE, 'Q'), 'YYYY-MM-DD') FROM dual; -- 上个季度最后一天(可以用本季度第一天减去1得到) SELECT t
------------------------------------------------ Oracle 日期------------------------------------------
-- 本季度第一天
SELECT to_char(TRUNC(SYSDATE, 'Q'), 'YYYY-MM-DD') FROM dual;
-- 上个季度最后一天(可以用本季度第一天减去1得到)
SELECT to_char(TRUNC(SYSDATE, 'Q') - 1, 'YYYY-MM-DD') FROM dual;
-- 上个季度第一天(本季度第一天 减 3个月)
SELECT to_char(add_months(TRUNC(SYSDATE, 'Q'), -3), 'YYYY-MM-DD')
FROM dual;
-- 上个季度第一天(本季度减一个月之后的月份的最后一天)
select to_char(last_day(add_months(trunc(sysdate, 'Q'), -1)), 'yyyy-mm-dd')
from dual
--№1: 取得当前日期是本月的第几周
select to_char(sysdate,'YYYYMMDD W HH24:MI:SS') from dual;
select to_char(sysdate, 'W') from dual;
--№2:取得当前日期是一个星期中的第几天,注意星期日是第一天
select sysdate, to_char(sysdate, 'D') from dual;
--类似:
select to_char(sysdate, 'yyyy') from dual; --当前年
select to_char(sysdate, 'Q' ) from dual; --当前季度
select to_char(sysdate, 'mm') from dual; --当前月
select to_char(sysdate, 'dd') from dual; --当前日
--№3:取当前日期是星期几的中文显示:
select to_char(sysdate, 'day') from dual;
--№4:如果一个表在一个date类型的字段上面建立了索引,如何使用
alter session set NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
--№5: 得到当前的日期
select sysdate from dual;
--№6: 得到当天凌晨0点0分0秒的日期
select to_char(trunc(sysdate), 'yyyymmdd hh:mi:ss' ) from dual;
-- 得到这天的最后一秒
select trunc(sysdate) + 0.99999 from dual;
-- 得到小时的具体数值
select trunc(sysdate) + 1 / 24 from dual;
select trunc(sysdate) + 7 / 24 from dual;
--№7:得到明天凌晨0点0分0秒的日期
select trunc(sysdate + 1) from dual;
select trunc(sysdate) + 1 from dual;
--№8: 本月一日的日期
select trunc(sysdate, 'mm') from dual;
--№9:得到下月一日的日期
select add_months(trunc(sysdate, 'mm'), 1) from dual;
select trunc(add_months(sysdate, 1), 'mm') from dual;
-- №10:返回当前月的最后一天?
select last_day(sysdate) from dual;
select last_day(trunc(sysdate)) from dual;
select trunc(last_day(sysdate)) from dual;
select trunc(add_months(sysdate, 1), 'mm') - 1 from dual;
--№11: 得到一年的第一天
select trunc(sysdate, 'y') from dual
--№11: 得到一年的每一天
select trunc(sysdate, 'yyyy') + rn - 1 date0
from (select rownum rn from all_objects where rownum
--№12:今天是今年的第N天
SELECT TO_CHAR(SYSDATE, 'DDD') FROM DUAL;
--№13:如何在给现有的日期加上2年
select add_months(sysdate, 24) from dual;
--№14:判断某一日子所在年分是否为润年
select last_day(trunc(sysdate, 'yyyy') + 31) from dual -- 通过一年的第一天加上31天到2月,然后取2月最后一天
select decode(to_char(last_day(trunc(sysdate, 'y') + 31), 'dd'),
'29',
'闰年',
'平年')
from dual;
--№15:判断两年后是否为润年
select decode(to_char(last_day(trunc(add_months(sysdate, 24), 'y') + 31), 'dd'),
'29',
'闰年',
'平年')
from dual;
--№16:得到日期的季度
select trunc(sysdate, 'mi') from dual ;
select to_number(to_char(sysdate,'mm')) from dual;
select ceil(to_number(to_char(sysdate,'mm'))/3) from dual;
select to_char(sysdate, 'Q') from dual;
--No17:返回某个月的最后一天
select to_char(last_day(sysdate), 'dd') from dual
--本周的第一天和最后一天,考虑到中国人习惯是周一为每周的第一天(国际惯例是周日为第一天,oracle也是这样)
select trunc(sysdate,'d')+1,trunc(sysdate,'d')+7 from dual where to_char(sysdate,'day')'星期日'
union all
select trunc(sysdate,'d')+1-7,trunc(sysdate,'d')+7-7 from dual where to_char(sysdate,'day')='星期日'
--当前季度的第一天
select to_char(trunc(sysdate,'Q'),'yyyy-mm-dd') from dual;
--当前季度的最后一天
SELECT to_char(add_months(TRUNC(SYSDATE, 'Q'), +3)-1, 'YYYY-MM-DD')
FROM dual;
select to_char(trunc(add_months(last_day(sysdate), -1) + 1), 'yyyy-mm-dd') "本月第一天",
to_char(last_day(sysdate), 'yyyy-mm-dd') "本月最后一天" FROM dual;

方法:1、利用“select*from user_indexes where table_name=表名”语句查询表中索引;2、利用“select*from all_indexes where table_name=表名”语句查询所有索引。

oracle asm指的是“自动存储管理”,是一种卷管理器,可自动管理磁盘组并提供有效的数据冗余功能;它是做为单独的Oracle实例实施和部署。asm的优势:1、配置简单、可最大化推动数据库合并的存储资源利用;2、支持BIGFILE文件等。

在oracle中,可以利用“TO_SINGLE_BYTE(String)”将全角转换为半角;“TO_SINGLE_BYTE”函数可以将参数中所有多字节字符都替换为等价的单字节字符,只有当数据库字符集同时包含多字节和单字节字符的时候有效。

在Oracle中,可利用lsnrctl命令查询端口号,该命令是Oracle的监听命令;在启动、关闭或重启oracle监听器之前可使用该命令检查oracle监听器的状态,语法为“lsnrctl status”,结果PORT后的内容就是端口号。

在oracle中,可以利用“drop sequence sequence名”来删除sequence;sequence是自动增加数字序列的意思,也就是序列号,序列号自动增加不能重置,因此需要利用drop sequence语句来删除序列。

在oracle中,可以利用“select ... From all_tab_columns where table_name=upper('表名') AND owner=upper('数据库登录用户名');”语句查询数据库表的数据类型。

方法:1、利用“LOWER(字段值)”将字段转为小写,或者利用“UPPER(字段值)”将字段转为大写;2、利用“REGEXP_LIKE(字符串,正则表达式,'i')”,当参数设置为“i”时,说明进行匹配不区分大小写。

方法:1、利用“alter system set sessions=修改后的数值 scope=spfile”语句修改session参数;2、修改参数之后利用“shutdown immediate – startup”语句重启服务器即可生效。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool