π
π
π
π
Databases
Searchβ¦
π
π
π
π
Databases
Table of contents
SQL
Getting Started
PgAdmin Tool
Data Types
Database
Table
Order of SQL Execution
Advance Table
Joins
Functions
Indexing
Summarization
MongoDB
Redis
Cassandra
Powered By
GitBook
Getting Started
Starting Database with Docker
docker
run --name
<
docker_name
>
-e
POSTGRES_PASSWORD
=<
password
>
-d -p
5432
:5432 postgres:13.3
β
docker
exec
-it
<
docker_name
>
bash
β
psql -U postgres
Installing PostgreSQL on windows
https://www.postgresql.org/download/windows/
Installing PostgreSQL on MacOS
β
https://www.postgresql.org/download/macosx/
β
Setup and Basics : using apt
Installation
sudo
apt-get
install
postgresql
Usage commands
service
postgresql
Switch to default user
sudo su postgres
Getting Started
Connect to a database
Connection options:
-h, --host
=
HOSTNAME
# database server host or socket directory
# (default: "local socket")
-p, --port
=
PORT
# database server port
# (default: "5432")
-U, --username
=
USERNAME
# database user name (default: "root")
-w, --no-password
# never prompt for password
-W, --password
# force password prompt (should happen automatically)
1.
Here port : 5432 is default and can be get from
psql --help
2.
postgres
is the
super user
.
Create another user and connect using that.
3.
to connect to database with user :
\c db_name user_name
Commands
-- to list all tables
\dt
β
-- to list all databases
\l
β
-- to list all table spaces
\db
β
-- to list all schemas
\dn
β
-- to list all indices
\di
β
-- to list all sequences
\ds
β
-- to list all roles
\dg
β
-- to list data types
\dT
β
-- to list all domain datatypes
\dD
β
-- to list all views
\dv
β
-- to list previous commands
\g
β
-- to list Command History
\s
β
-- to run command from file
\i filename
-- it should be inside the server
β
-- to list help
\h
\h
create
table
β
-- to display null
\pset
null
(
null
)
β
-- to make terminal better
\pset linestyle unicode
\pset border
2
β
-- to watch a command in time
\watch
2
β
-- to turn on timing
\timing
Load Data
Download the sample data file from here
https://drive.google.com/file/d/1vsFVuybjNDacNaV5LmaSI__a6dCpEdmT/view?usp=sharing
image
Previous
SQL
Next
PgAdmin Tool
Last modified
17d ago
Copy link
Outline
Starting Database with Docker
Installing PostgreSQL on windows
Installing PostgreSQL on MacOS
Setup and Basics : using apt
Getting Started
Commands
Load Data