Withdata Software provide some ETL (Extract-Transform-Load) tools for PostgreSQL: FileToDB Load TXT, CSV, TSV, XML, JSON, Excel, SQL, RDF, INI data to PostgreSQL DBToFile Export PostgreSQL data to TXT, CSV, TSV, XML, JSON, Excel, SQL files DBCopier Copy data between PostgreSQL and ... Read more
Category Archives: PostgreSQL
How to get index column names of a table from PostgreSQL
select i.relname as index_name, a.attname as column_name from pg_class t, pg_class i, pg_index ix, pg_attribute a, pg_namespace n where t.oid = ix.indrelid and i.oid = ix.indexrelid and a.attrelid = t.oid and a.attnum = ANY(ix.indkey) and n.oid=t.relnamespace and t.relkind = 'r' and ... Read more
How to get primary key of a table from PostgreSQL
SELECT pg_attribute.attname, format_type(pg_attribute.atttypid, pg_attribute.atttypmod) FROM pg_index, pg_class, pg_attribute, pg_namespace WHERE pg_class.oid = 'my_table_name'::regclass AND indrelid = pg_class.oid AND nspname = 'my_schema_name' AND pg_class.relnamespace = pg_namespace.oid ... Read more
How to get column names from PostgreSQL table
select column_name from information_schema.columns where table_name='my_table_name' see also: How to get column names from Sql Server table How to get column names from DB2 table How to get column names from Oracle table How to get column names from Mysql table How to get column names from SQLite ... Read more
How to execute sql file via command line for PostgreSQL
Use psql psql -U username -d myDataBase -a -f myInsertFile More information: http://blog.manoharbhattarai.com.np/2013/04/03/execute-sql-file-from-command-line-in-postgresql/ ... Read more
How to limit the number of rows returned by a PostgreSQL query
In MySQL, you can use “Limit <skip>,<count>”, like this: select * from sometable order by name limit 20,10 How to do in PostgreSQL? You’d use “Limit <count> offset <skip>”, like this: select * from sometable order by name limit 10 offset ... Read more
Replace Update or Insert a row Into PostgreSQL Table
In Mysql, if you want to either updates or inserts a row in a table, depending if the table already has a row that matches the data, you can use “ON DUPLICATE KEY UPDATE”. How to do it in PostgreSQL? A way to do an “UPSERT” in postgresql is to do two sequential ... Read more