Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql select from table inside docker container bash [closed]

I can access my postgresql db inside docker container and the see the postgresql bash with this command :

docker exec -it  <container-name> psql -U <dataBaseUserName> <dataBaseName>

But I need to see the data I inserted to the table with the api. Is there a way to perform select statement here?

like image 663
Ali Mansur Avatar asked Jul 31 '26 23:07

Ali Mansur


1 Answers

Whenever you access your container using the

docker exec -it <container-name> psql -U <username> <database> 

you can run any PSQL-Query you like. To list all the tables within your database you can use

\dt

After you identified the table you want to query you can call any select, update or delete statement you like, e.g.:

SELECT * FROM <tablename>;

See the official PostgresQL documentation for more details.

However, I highly recommend using tools such as DBeaver or Database-Tools integrated within your IDE to manage your databases. Connecting your databases running in a container is as easy as running the docker exec command. But the user interface and integrated shortcuts of those tools to e.g. generate SQL-Queries makes it much more easy to access and manage your databases.

like image 60
MoDo Avatar answered Aug 02 '26 11:08

MoDo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!