$ settings --editor

$ settings --general

$ save --settings

SQL for beginners

Creating a table with CREATE TABLE #

So far we have only worked with tables that were already there for us (customers, products, orders, order_items). The CREATE TABLE statement is how you build a brand new table from scratch:

CREATE TABLE table_name (
    column_1,
    column_2,
    column_3
);
  • table_name: The name of the new table.
  • column_1, column_2, column_3: The names of the columns the table will have.

Every row inserted into this table will have these columns, in this order. In the next lessons you will learn how to give each column a data type and extra rules (like requiring a value, or being unique).


Exercise #

Write a command that creates a new table called reviews with the columns id, product_id, rating, and comment.

Tests #

  • A table named reviews exists.
  • The reviews table has the columns id, product_id, rating, and comment.
Solution
CREATE TABLE reviews (
    id,
    product_id,
    rating,
    comment
);
Output will be displayed here