Skip to main content

Posts

Showing posts from October, 2023

My PostgreSQL crash course

PostgreSQL is a powerful open source relational database. If you have worked with MySQL before, PostgreSQL will feel familiar but with additional enterprise features. First install PostgreSQL using your package manager. On Ubuntu: sudo apt install postgresql Once installed, check service status: sudo systemctl status postgresql Switch to postgres user: sudo -i -u postgres Enter PostgreSQL prompt: psql To list databases: \l To create a new database: CREATE DATABASE mydb; To connect to it: \c mydb To create a table: CREATE TABLE users ( id SERIAL PRIMARY KEY, name TEXT, email TEXT ); To insert data: INSERT INTO users (name, email) VALUES ('John', '[john@example.com](mailto:john@example.com)'); To query data: SELECT * FROM users; To exit: \q PostgreSQL is reliable, standards compliant, and production ready. Disclaimer: If you follow the information here, there is no warranty , I am not liable if it deletes your data, gets you hacke...