oracle between and 邊界問題
--創建一個表
create table test_hsj(
oracle索引分類?id int primary key,
num varchar2(12),
regDate date
)
oracle or。select * from test_hsj;
--插入測試數據
insert into test_hsj values(1,'1', to_date('2015-05-01','yyyy-MM-dd'))
insert into test_hsj values(2,'2', to_date('2015-06-01','yyyy-MM-dd'))
sql having,insert into test_hsj values(3,'3', to_date('2015-05-11','yyyy-MM-dd'))
insert into test_hsj values(4,'4', to_date('2015-05-01','yyyy-MM-dd'))
insert into test_hsj values(5,'5', to_date('2015-06-21','yyyy-MM-dd'))
insert into test_hsj values(6,'6', to_date('2015-06-11','yyyy-MM-dd'))
oracle行轉列?insert into test_hsj values(7,'7', to_date('2016-06-11','yyyy-MM-dd'))
insert into test_hsj values(8,'8', to_date('2014-04-01','yyyy-MM-dd'))
--查詢驗證,日期在 5 月到6月份之間的數據 如果轉換為日期的時候,只有年月的時候會默認取1號 between and 會包含兩端 包含兩端
--1 結論:對于日期類型 between and 包括 >= and <=
sql,select * from test_hsj where regdate between to_date('2015-05','yyyy-MM') and to_date('2015-06','yyyy-MM')
--如果只有年月 則只會去 1號
select to_date('2015-05','yyyy-MM') from dual
--如果只有年,那么回去當前月份 的1 號
oracle like in、select to_date('2014','yyyy') from dual
--2 結論: 對于數值類型 between and 等效 >= and <=
select * from test_hsj where id between 1 and 5;
--3 結論: 對于字符類型 between and 等效 >= and <=
oracle timestamp。select * from test_hsj where num between '1' and '5';
--總結論: 對于orcle數據庫 between and 等效 >= and <=
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态