Skip to content

Creating a database

Course: SQL databases - chapter 4

You can start a Potgres database in a few ways -

Using neondb

https://neon.tech/ is a decent service that let’s you create a server.

postgresql://username:password@ep-broken-frost-69135494.us-east-2.aws.neon.tech/calm-gobbler-41_db_2253874
Using docker locally
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
postgresql://postgres:mysecretpassword@localhost:5432/postgres?sslmode=disable
Using docker on windows

How to run postgrSQL in windows terminal(if you have docker installed).

  • fist run docker gui application that help in running commands in terminal.
  • After that run it with the docker instance by the help of following command . – for the first time if the image is not downloaded . – docker run --name my-postgres1 -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres. – if the docker image is there, prior to use the it can simply be runned by docker run <image name>.
  • After that , – use docker exec -it my-postgres1 psql -U postgres -d postgres this command in terminal . – then enter the password and it will connect to localhost Postgress instance . – now you will be inside the postress command line that looks like postgres-# .
  • U can check it by running \\dt , (the command to display all the tables.)

💡 The connection string is similar to the string we had in mongoose.

where does harkirat live ⇒ [1, 2, 2, 2, 3001, 100]

Harkirat lives in INdia ⇒ [1, 2, 2, 2, 2,2 ]

Harkirat is from chandigarh ⇒ [1, 2, 2, 2, 3]

Harkirat has been living in india, chandigarh ⇒ [1, 2, 2, 2, 2, 3]

The world is round ⇒ [1, 2, 10001, 1001, 001001]

Pacman is such a good game ⇒ [100, 10001, 20020, 1-001, 100]