https://github.com/timowest12/pgcommands
https://github.com/timowest12/pgcommands
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/timowest12/pgcommands
- Owner: Timowest12
- Created: 2024-03-14T20:44:56.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-18T18:55:12.000Z (over 2 years ago)
- Last Synced: 2025-07-02T03:05:41.082Z (about 1 year ago)
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Project Commands Collection
### Instant command
###### setup, run initiate master and map port
docker run --name instance-name -e POSTGRES_PASSWORD=secretpassword -p 5432:5432 -d postgres
### Docker Commands
###### Pull PostgreSQL Image
docker pull postgres
###### Run PostgreSQL Container
docker run --name instance-name -e POSTGRES_PASSWORD=secretpassword -d postgres
###### Bash into PostgreSQL Container
docker exec -it instance-name bash
### PostgreSQL Commands
###### Log into PostgreSQL(need to be in container)
psql -U postgres
###### List All PostgreSQL Users
\du
###### Create User with Password
CREATE USER username WITH PASSWORD 'secretpassword';
###### Create User that Expires at Certain Moment
CREATE USER name WITH PASSWORD 'secretpassword' VALID UNTIL '2005-01-01';
###### Drop a user
DROP USER IF EXISTS username;
###### Create a Schema
CREATE SCHEMA IF NOT EXISTS schemaname;
###### Drop a Schema
DROP SCHEMA IF EXISTS schemaname;
###### List all schemas
select nspname from pg_catalog.pg_namespace;
###### Create table
CREATE TABLE test (
id text,
name text
)
###### INSERT
INSERT INTO test (id,name) VALUES ('2','name')