timezone brasil postgresql 1

timezone brasil postgresql

## Edit file
/var/lib/postgresql/data/postgresql.conf

# Update
timezone='America/Sao_Paulo'

## If you're in docker container run:
apt update
apt install nano

# Run to edit file
nano /var/lib/postgresql/data/postgresql.conf

Here is what the above code is Doing:
1. We’re creating a new variable called timezone and setting it equal to the string ‘America/Sao_Paulo’.
2. We’re updating the apt package list.
3. We’re installing the nano text editor.
4. We’re opening the postgresql.conf file in the nano text editor.

## Restart postgresql
service postgresql restart

## Create database
createdb -h localhost -p 5432 -U postgres -W -E UTF8 -T template0 mydb

## Create user
createuser -h localhost -p 5432 -U postgres -W -S -D -R myuser

## Create table
psql -h localhost -p 5432 -U postgres -W -d mydb -c “CREATE TABLE mytable (id serial PRIMARY KEY, name VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL);”

## Insert data
psql -h localhost -p 5432 -U postgres -W -d mydb -c “INSERT INTO mytable (name, email) VALUES (‘John Doe’, ‘john@doe.com’);”

## Select data
psql -h localhost -p 5432 -U postgres -W -d mydb -c “SELECT * FROM mytable;”

## Delete data
psql -h localhost -p 5432 -U postgres -W -d mydb -c “DELETE FROM mytable WHERE id = 1;”

## Update data
psql -h localhost -p 5432 -U postgres -W -d mydb -c “UPDATE mytable SET name = ‘Jane Doe’ WHERE id = 1;”

## Drop table
psql -h localhost -p 5432 -U postgres -W -d mydb -c “DROP TABLE mytable;”

## Drop database
dropdb -h localhost -p 5432 -U postgres -W mydb

## Drop user
dropuser -h localhost -p 5432 -U postgres -W myuser

## Backup database
pg_dump -h localhost -p 5432 -U postgres -W -F t -b -v -f mydb.tar mydb

## Restore database
pg_restore -h localhost -p 5432 -U postgres -W -d postgres -v “mydb.tar”

## Backup database to file
pg_dump -h localhost -p 5432 -U postgres -W -F p -b -v -f mydb.sql mydb

## Restore database from file
psql -h localhost -p 5432 -U postgres -W -d postgres -f mydb.sql

## Backup database to file (compressed)
pg_dump -h localhost -p 5432 -U postgres -W -F t -b -v -f mydb.tar mydb

## Restore database from file (compressed)
pg_restore -h localhost -p 5432 -U postgres -W -d postgres -v “mydb.tar”

## Backup database to file (compressed)
pg_dump -h localhost -p 5432 -U postgres -W -F p -b -v -f mydb.sql mydb

## Restore database from file (compressed)
psql -h localhost -p 5432 -U postgres -W -d postgres -f mydb.sql

## Backup database to file (compressed)
pg_dump -h localhost -p 54

Similar Posts