Last active
June 21, 2022 13:09
-
-
Save mttjohnson/77ea3440517509a8ee0a1df6a81d6352 to your computer and use it in GitHub Desktop.
PostgreSQL Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.postgresql.org/download/linux/debian/ | |
# Installing Postgres Client on Debian | |
apt-get update && apt-get install -y lsb-release && apt-get clean all | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | |
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list | |
apt-get update | |
apt-get -y install postgresql-client-13 | |
# List available packages | |
apt list postgres\* | |
# Client Version | |
psql --version | |
# Testing Connectivity | |
ping postgres | |
psql 'host=postgres port=5432 dbname=congenius_development user=postgres' | |
# Settings up a default connection file containing credentials | |
# https://www.postgresql.org/docs/current/libpq-pgpass.html | |
echo " | |
hostname:port:database:username:password | |
" > ~/.pgpass | |
chmod go-rwx ~/.pgpass | |
# SQL queries getting info about server | |
\list | |
\c congenius_development | |
\dt | |
SELECT version(); | |
SHOW server_version; | |
SELECT datname FROM pg_database WHERE datistemplate = false; | |
SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment