刚开始学习oracle,遇到一个问题:
用命令
select ename, sal, hiredate from emp
where hiredate > '20-2月-80';提示无效的月份(not a valid month).
开始我还以为是输入问题,然后把输出的月份复制过来用还是提示无效的月份。
我想是不是因为oracle不能识别中文啊?
但是输出中文是没有问题啊
论坛里的达人们,求教啊
新手求赐教,求赐教。
用命令
select ename, sal, hiredate from emp
where hiredate > '20-2月-80';提示无效的月份(not a valid month).
开始我还以为是输入问题,然后把输出的月份复制过来用还是提示无效的月份。
我想是不是因为oracle不能识别中文啊?
但是输出中文是没有问题啊
论坛里的达人们,求教啊
新手求赐教,求赐教。
where hiredate > to_date('1980-02-20','yyyy-mm-dd');
select ename, sal, hiredate from emp
where hiredate > '20-2月-80';
这条语句在他的机器上运行完全是没有问题的啊……
如果跟你的输入的 '20-2月-80',格式不匹配的话是不能直接比较的查看你的nls_langurage是否为SIMPLIFIED CHINESE:
SQL> show parameter nls_languageNAME TYPE VALUE
------------------------------------ ----------- ------------------------------
nls_language string SIMPLIFIED CHINESE
ORA-00942: 表或视图不存在
然后网上找到这个查了下:SQL> select userenv('language') from dual;USERENV('LANGUAGE')
----------------------------------------------------
SIMPLIFIED CHINESE_CHINA.ZHS16GBK这个是怎么回事啊???
--to_char 至少不用考虑字符集..to_date 要不要考虑真没注意过
select * from test where to_char(hiredate ,'yyyymmdd') > '20080220';select * from test where hiredate > to_date('20080220','yyyymmdd')