PostgreSQL – Extract Digit Only from Column with Text Value

By | December 8, 2013
select substring(mycolumn from 'd+') from mytable

You may want to copy digit values from one column to another column which it’s data type is integer. Below is the sample of usage:

update dev_01 set lot_number = substring(lot from 'd+')::int;

Leave a Reply

Your email address will not be published. Required fields are marked *

13 − 5 =