Posts

Showing posts with the label PostgreSQL

Postgres select columns names without default value

 PostgreSQL select column names where there is no default value :   SELECT column_name, column_default FROM information_schema.columns WHERE (table_schema, table_name) = ('public', 'test') AND column_default IS NULL ORDER BY ordinal_position;  

Excel CANCAT date and time to POSTGRESQL timestamp

Image
 Formula example:   =TEXT(E3;"yyyy-mm-dd")&" "&TEXT(G3;"hh:mm:ss")

Find duplicates in Postgres table and remove them

 To find all duplicates in table: SELECT name, COUNT( name ) FROM client GROUP BY name HAVING COUNT( name )> 1 ORDER BY name; To remove one: DELETE FROM client a USING client b WHERE a.id < b.id AND a.name = b.name;