Skip to main content

Creating a SQL Exercise

How to create a SQL activity using CodeHS Create

Written by Sara Jenis
Banner: Free feature

You can make your own autograded SQL problems in CodeHS Create. There are only a few steps to writing a good SQL program, and you can see a demo in the video below!

Create an assignment from the Create app or Assignments app

Step 1: Create a SQL Exercise

  • Click Create in the left-hand navigation menu to go to the Create app

  • Click Create New Assignment

  • Choose Coding Exercise > select a SQL Program Type

  • Fill in assignment details: title, description, and starter code

    GIF of the assignment creation process from the Create app

Step 2: Add Data and Starter/Solution Code

  • Click '...' next to the assignment > click Edit

  • Click the SQL Setup tab near the top

  • Add any SQL code needed to set up the exercise (such as creating tables and inserting data) in the setup.sql file, and add the table names as a comma-separated list into the tables file.

  • Be sure to click Save SQL Setup.

  • Enter your Starter Code and Solution Code using the tabs near the top.

GIF demonstrating how to change SQL setup, and add starter code and solution code

SQL Setup Code

You can use this sample code to help create tables and add data:


CREATE TABLE Name (id, first_name, last_name, house);
INSERT into Name values ("1", "Harry", "Potter", "1");
INSERT into Name values ("2", "Ron", "Weasley", "1");
INSERT into Name values ("3", "Hermione", "Granger", "1");
INSERT into Name values ("4", "Severus", "Snape", "4");

CREATE TABLE House (house_name, house_id);
INSERT into House values ("Gryffindor", "1");
INSERT into House values ("Ravenclaw", "2");
INSERT into House values ("Hufflepuff", "3");
INSERT into House values ("Slytherin", "4");


Still have questions? Contact our team at support@codehs.com to learn more!

Did this answer your question?