# Connecting to a Postgres server
```shell
$ psql -h <hostname> -p <port> -d <dbname> -U <username> --password
```
# Create a database
## Command line
```shell
$ createdb <dbname>
```
## SQL
```postgresql
CREATE DATABASE <dbname>;
```
# List Databases
```postgresql
-- Simple list
\l
-- Add Size, Tablespace, Description info
\l+
```
# Switching to a database
```shell
\c <dbname>
```
# List tables
```postgresql
-- Standard list
\d
-- Include Size, Description
\d+
```
# Show database schema
```shell
$ pg_dump -s -U <username> -h <hostname> <dbname> > schema.sql
```
# Show table schema
```postgresql
-- Simple schema
\d <table>
-- Include Storage, Stats target, Description
\d+ <table>
```
# Help
```postgresql
\?
```