Category: PostgreSQL
-
Some ETL (Extract-Transform-Load) tools for PostgreSQL
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 other rational databases MongoToDB Ease your MongoDB to PostgreSQL converting work DBBlobEditor Edit…
-
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 t.relname=’my_table_name’ and n.nspname=’my_schema_name’ See also: How to get index column names of a table…
-
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 AND pg_attribute.attrelid = pg_class.oid AND pg_attribute.attnum = any(pg_index.indkey) AND indisprimary See official version: http://wiki.postgresql.org/wiki/Retrieve_primary_key_columns See also: How to get primary key of a table from SQLite How to get primary…
-
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 table Some PostgreSQL tools you can try:…
-
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/
-
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 20 In Oracle: https://www.withdata.com/blog/oracle/how-to-limit-the-number-of-rows-returned-by-an-oracle-query-after-ordering.html . In SQL Server: https://www.withdata.com/blog/sql-server/the-sql-server-equivalent-for-the-mysql-limit.html . In DB2: https://www.withdata.com/blog/db2/the-db2-equivalent-for-the-mysql-limit.html . In Mysql: https://www.withdata.com/blog/mysql/how-to-limit-the-number-of-rows-returned-by-an-mysql-query.html .…
-
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 UPDATE/INSERT statements…