Skip to content

Instantly share code, notes, and snippets.

@jessepinkman9900
Last active April 24, 2024 03:12
Show Gist options
  • Save jessepinkman9900/3f65e33ffd84abc84bd331d464d55c11 to your computer and use it in GitHub Desktop.
Save jessepinkman9900/3f65e33ffd84abc84bd331d464d55c11 to your computer and use it in GitHub Desktop.
commands for Postgres with docker

Docker

  1. get the container running on port 5000 NOTE: 5000:5432 => map from 5432 to 5000 docker run --name dev-postgres -e POSTGRES_PASSWORD=pwd -p 5000:5432 -d postgres

  2. access shell for that container docker exec -it dev-postgres bash

Shell commands for postgres

  1. enter the psql command line psql -h localhost -U postgres
  2. list databses \l
  3. connect to a db \c <database_name> <optional: as_user> example: \c database spring_auth
  4. list tables \dt
  5. get schema of table, i.e descirbe \d table_name example: \d users
  6. create user CREATE USER user_name WITH [OPTION]; [3]

Issue:

For using extra types and general purpose utilities that are not supported by the Hibernate ORM core and optimiser for jpa and hibernate solutions can be found in resource #5

Resources

  1. https://chartio.com/resources/tutorials/how-to-list-databases-and-tables-in-postgresql-using-psql/
  2. https://www.postgresqltutorial.com/postgresql-describe-table/
  3. https://kb.objectrocket.com/postgresql/how-to-use-the-postgres-create-user-command-1449
  4. https://www.codementor.io/@engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb
  5. https://github.com/vladmihalcea/hibernate-types
  6. https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment