to_char(number) function in postgres

You need to supply a format mask. In PostgreSQL there is no default: select to_char(1234, ‘FM9999′); If you don’t know how many digits there are, just estimate the maximum: select to_char(1234, ‘FM999999999999999999′); If the number has less digits, this won’t have any side effects. If you don’t need any formatting (like decimal point, thousands separator) … Read more

Spring Boot “PSQLException: FATAL: sorry, too many clients already” when running tests

Since there hasn’t been a suggested answer I am posting my solution. Short version: decrease the connection pool size in test properties: spring.datasource.hikari.maximum-pool-size=2 Longer version: Spring Boot 2 uses HikariCP by default for connection pooling, which has a default value of 10 for connection pool size (as of Jan 2019). While running a lot of … Read more

PostGIS – convert multipolygon to single polygon

I used ST_DUMP to convert a table of multipolygon geometries in PostgreSQL to a new table with polygon geometries and other columns of data. CREATE TABLE poly AS –poly will be the new polygon table WITH dump AS ( SELECT id, test, –columns from your multipolygon table (ST_DUMP(geometry)).geom AS geometry FROM multi –the name of … Read more

ERROR: missing data for column when using \copy in psql

Three possible causes: One or more lines of your file has only 4 or fewer space characters (your delimiter). One or more space characters have been escaped (inadvertently). Maybe with a backslash at the end of an unquoted value. For the (default) text format you are using, the manual explains: Backslash characters (\) can be … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)