← Back to PostgreSQL Menu | 🏠 Hub
| Feature | MySQL | PostgreSQL |
|---|---|---|
| ACID compliance | InnoDB only | ✅ Full |
| JSON support | Basic JSON | ✅ JSONB (indexed, fast) |
| Arrays | ❌ | ✅ Native ARRAY type |
| Full-text search | Basic | ✅ Built-in tsvector |
| Window functions | Limited | ✅ Full SQL standard |
| Custom types | ❌ | ✅ CREATE TYPE |
| Geospatial | Basic | ✅ PostGIS extension |
| Default port | 3306 | 5432 |
# Windows: postgresql.org/download/windows → EDB installer # Mac: brew install postgresql@16 # Ubuntu: sudo apt install postgresql postgresql-contrib # Start service # Windows: Services ထဲ "postgresql-x64-16" → Start # Mac/Linux: sudo systemctl start postgresql # Check version psql --version # psql (PostgreSQL) 16.x # Connect psql -U postgres # connect as postgres superuser # prompt: postgres=#
-- psql commands (meta-commands start with \) \l -- list databases \c mydb -- connect to database \dt -- list tables in current db \d users -- describe table structure \du -- list users/roles \q -- quit -- Create database & user CREATE DATABASE myapp; CREATE USER myuser WITH PASSWORD 'mypassword'; GRANT ALL PRIVILEGES ON DATABASE myapp TO myuser; -- Connect to new db \c myapp -- Run SQL file \i /path/to/setup.sql
-- pgAdmin Quick Start
1. Open pgAdmin → Servers → PostgreSQL → Connect
2. Databases → Right-click → Create → Database
3. Query Tool → Write SQL → F5 to run
-- VS Code: SQLTools extension
-- Extension: "SQLTools" + "SQLTools PostgreSQL/Redshift"
-- Connect settings:
{
"name": "Local PG",
"driver": "PostgreSQL",
"server": "localhost",
"port": 5432,
"database": "myapp",
"username": "postgres"
}
-- Supabase.com = PostgreSQL + REST API + Auth + Storage -- Free tier: 500MB database, unlimited API calls -- Setup: 1. supabase.com → Sign up → New Project 2. Get connection string: postgresql://postgres:[password]@db.xxx.supabase.co:5432/postgres -- Features: - PostgreSQL database (full access) - Auto-generated REST API - Authentication (email, OAuth) - File Storage - Realtime subscriptions -- Great for: personal projects, startups, learning! -- Production: AWS RDS, Google Cloud SQL, Neon.tech
← PostgreSQL Menu | Next: PostgreSQL 02 → Tables →