postgresql isnumeric

 
  

WITH test(x) AS ( VALUES (''), ('.'), ('.0'), ('0.'), ('0'), ('1'), ('123'), ('123.456'), ('abc'), ('1..2'), ('1.2.3.4')) SELECT x , x ~ '^[0-9]*.?[0-9]*$' AS isnumeric FROM test;

  

------下面才是正解

 

WITH test(x) AS (     VALUES (''), ('.'), ('.0'), ('0.'), ('0'), ('1'), ('123'),     ('123.456'), ('abc'), ('1..2'), ('1.2.3.4'), ('1x234'), ('1.234e-5'))

SELECT x      , x ~ '^([0-9]+[.]?[0-9]*|[.][0-9]+)$' AS isnumeric FROM test;

 

你可能感兴趣的:(postgresql)