CREATE OR REPLACE VIEW V_ISNUMBER AS
SELECT 'SDFU0329' COL FROM DUAL
UNION ALL
SELECT 'SDFU0329$' COL FROM DUAL
UNION ALL
SELECT 'SDFUU' COL FROM DUAL
UNION ALL
SELECT '0329' COL FROM DUAL
UNION ALL
SELECT '' COL FROM DUAL
UNION ALL
SELECT '329$' COL FROM DUAL
UNION ALL
SELECT NULL COL FROM DUAL;
--使用TRANSLATE()函数判断
SELECT COL
FROM V_ISNUMBER T
WHERE COL IS NOT NULL
AND TRANSLATE(COL, '$0123456789', '$') IS NULL;
--使用正则REGEXP_LIKE()
SELECT COL
FROM V_ISNUMBER T
WHERE REGEXP_LIKE(COL, '^[0-9]+$');
--使用正则REGEXP_REPLACE()
SELECT COL
FROM V_ISNUMBER T
WHERE COL IS NOT NULL
AND REGEXP_REPLACE(COL, '[0-9]') IS NULL;
判断值中是否为纯数字,当然,字段类型是字符型的。方法很多,上面用了三个简单的函数做以判断,还是很简单实用的。
oracle 判断值里是否为纯数字
最新推荐文章于 2024-07-30 17:39:10 发布