SQL statements with subqueries
63.3
Exercise

Copying data from one table to another - 2

There is a students table below with a few columns and a few records rows.

Write a set of SQL statements to:

  1. create a new table courses with the following columns, data types and constraints.

    column data type constraint
    id INTEGER NOT NULL, PRIMARY KEY, AUTOINCREMENT
    name TEXT NOT NULL
  2. Extract distinct names of all not-null unique courses students are enrolled in, from students table, and insert them in the newly created courses table.