Installing a Database System
Before writing SQL, you need a database system installed on your machine. For beginners, MySQL and PostgreSQL are the most popular choices. Both are free, open-source, and widely used in the industry.
MySQL is known for its speed and simplicity, making it a great first database. PostgreSQL offers more advanced features like JSON support and custom data types. SQLite requires no installation at all — it is a single file on your computer.
- MySQL: Download from https://dev.mysql.com/downloads/ — install MySQL Community Server
- PostgreSQL: Download from https://www.postgresql.org/download/ — includes pgAdmin GUI
- SQLite: No installation needed — comes built into Python and most programming languages
- XAMPP: An all-in-one package that includes MySQL, Apache, and PHP for web development
-- After installing MySQL, log in via terminal:
-- mysql -u root -p
-- Check your MySQL version
SELECT VERSION();
-- For PostgreSQL, log in with:
-- psql -U postgres
-- Show all existing databases
SHOW DATABASES; - If you just want to practice SQL without installing anything, online tools like DB Fiddle (db-fiddle.com) or SQLite Online let you run SQL queries directly in your browser.
Database Tools & Creating Your First Database
A GUI (Graphical User Interface) tool makes working with databases much easier by letting you visualize tables, run queries, and manage your data visually. Most database systems come with or support popular GUI tools.
Let us create our first database. A database is a container that holds all your tables, views, and other objects. Think of it as a folder that organizes related data together.
- MySQL Workbench: Official GUI for MySQL with visual query builder and schema designer
- pgAdmin: Official GUI for PostgreSQL with dashboard and query tool
- DBeaver: Free universal database tool that works with MySQL, PostgreSQL, SQLite, and more
- DataGrip: JetBrains' professional database IDE (paid, with free trial)
-- Create a new database
CREATE DATABASE my_first_db;
-- Switch to the new database
USE my_first_db;
-- Verify you are in the right database
SELECT DATABASE();
-- If you need to delete a database (be careful!)
-- DROP DATABASE my_first_db;
-- Create a database only if it does not exist
CREATE DATABASE IF NOT EXISTS my_first_db; - Always use CREATE DATABASE IF NOT EXISTS to avoid errors when the database already exists. The DROP DATABASE command permanently deletes all data — use it with extreme caution.
