Skip to content

SQL Practice Guide

Hello Fellow Challengers!
We believe that practice truly makes perfect, hence we created this practical guide to assist you in your SQL mastery journey especially with the help of DB Fiddle.

DB Fiddle is an online platform that allows you to test and experiment with various database systems and SQL queries. It’s a powerful tool for testing and sharing SQL code without the need to set up a local database and a handy tool to quickly try out scripts and share them with others. 

Here’s a step-by-step tutorial on how to use DB Fiddle:

1. Access the DB Fiddle Website

Go to the DB Fiddle website at https://www.db-fiddle.com/. It’s a free and open-source platform, so you don’t need to create an account to get started.

2. Choose Your Database Engine

On the DB Fiddle homepage, you’ll see a list of database engines you can choose from. DB Fiddle supports various databases, including PostgreSQL, MySQL, SQLite, SQL Server, and Oracle. Select the database engine you want to work with by clicking on the respective icon. We’ll be using PostgreSQL v.15

3. Compose Your Schema

Next, you’ll be presented with a clean slate to define your database schema. You can create tables, define columns, and set data types. We have already prepared some schemas in advance for the SQL practice. All you need to do is copy and paste the schema below.

NOTE: Kindly ensure that you select PostgreSQL as your database type for the schema to work perfectly.

CREATE TABLE restaurants (
“id” VARCHAR(4),
“name” VARCHAR(16),
“city” VARCHAR(12),
“country” VARCHAR(14),
“launch_year” INTEGER,
“size” VARCHAR(6),
“occupancy” FLOAT
);
INSERT INTO restaurants
(“id”, “name”, “city”, “country”, “launch_year”, “size”, “occupancy”)
VALUES
(‘ax6t’, ‘Basira Lagos’, ‘Lagos’, ‘Nigeria’, ‘2001’, ‘large’, ‘0.8’),
(‘vg6w’, ‘Basira Accra’, ‘Accra’, ‘Ghana’, ‘2007’, ‘medium’, ‘0.7’),
(‘ds4t’, ‘Basira Joburg’, ‘Johannesburg’, ‘South Africa’, ‘2016’, ‘large’, ‘0.4’),
(‘gk7e’, ‘Basira Manhattan’, ‘New York’, ‘America’, ‘2022’, ‘small’, ‘0.6’),
(‘fd2l’, ‘Basira London’, ‘London’, ‘United Kingdom’, ‘2019’, ‘small’, ‘0.4’),
(‘py9r’, ‘Basira Abuja’, ‘Abuja’, ‘Nigeria’, ‘2011’, ‘medium’, ‘0.2’),
(‘lr3s’, ‘Basira PH’, ‘Portharcourt’, ‘Nigeria’, ‘2020’, ‘small’, ‘0.6’);

4. Write SQL Queries

Now, you can start writing SQL queries in the “SQL” tab. For instance, to retrieve all restaurants, you can use a simple SELECT statement:

5. Execute Queries

Click the “Run” button (or press Ctrl + Enter for PC or Cmd + Enter for macOS) to execute your SQL query. The results will be displayed in the “Results” tab below the query editor.

6. Share Your Fiddle

You can share your DB Fiddle with others by copying the URL from your browser’s address bar. This is handy for discussing and collaborating on SQL code with colleagues or seeking help on forums or Stack Overflow.

7. Save Your Fiddle

If you want to save your fiddle for future reference, click the “Save” button, and you’ll be given a unique URL that you can use to access your fiddle later.

That’s it! You now know how to use DB Fiddle to practice your SQL skills and queries. Happy querying!

Did you learn anything new? Share your new insights with us on Facebook, LinkedIn or Instagram and don’t forget to tag us!

Loading spinner

Previous Posts