Sunday, March 07, 2021

PostgreSQL intro

PostgreSQL :

CLI :

https://www.postgresql.org/docs/13/app-psql.html

FILES :

Linux : ~/.pgpass - pg pass

Win :   %APPDATA%\postgresql\pgpass.conf

format: hostname:port:database:username:password

env :   set PGPASSFILE=C:\Program Files\someapp\pgpass.conf

note :  if env PGPASSWORD is set, ~/.pgpass is not read

nopass: https://blog.sleeplessbeastie.eu/2014/03/23/how-to-non-interactively-provide-password-for-the-postgresql-interactive-terminal/

bash :  chmod u-x,go-rwx ~/.pgpass

*

psql CLI :

psql option dbname username

i.e. :

psql -c '\x' -c 'SELECT * FROM foo;'

echo '\x \\ SELECT * FROM foo;' | psql

psql <<EOF

\x

SELECT * FROM foo;

EOF

*

SWITCHES :

-c command

-d dbname

-h host

-U user

-W --password

-f command-input-file

-l == list all available databases

\x = toggle expanded table formatting mode

-o output-file.txt

*


PG tutorial :

Tutorials Point :

https://www.tutorialspoint.com/postgresql/postgresql_quick_guide.htm

*

https://www.postgresqltutorial.com/

Import CSV to SQL  in Postgre :

https://www.postgresqltutorial.com/import-csv-file-into-posgresql-table/

Export SQL to CSV from Postgre :

https://www.postgresqltutorial.com/export-postgresql-table-to-csv-file/


PG data types :

https://www.postgresqltutorial.com/postgresql-data-types/

*


PG Admin :

https://www.pgadmin.org/

https://www.pgadmin.org/download/

No comments: