Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Your First Table
CREATE TABLE basics
9. The VARCHAR column type
Entity Relationship Diagrams (ERD)
Summary

Instruction

Nice! Let's add another column to our example – but this time, it's not a number or a date:

CREATE TABLE airplane (
  id integer,
  max_passengers integer,
  production_date date,
  model varchar(32)
);

As you can see, we put varchar(32) for the column model. The data type varchar is a column type used to store text values, but what differentiates this data type from others is the pair of parentheses that follows. In the parentheses, you should specify the maximum length of any value in that column (32 stands for 32 characters). Try to keep it as small as possible; after all, the greater the value, the more space the database will require!

Exercise

Create a table named result with the following four columns:

  1. id – a number
  2. name – a text of 32 characters at most
  3. score – an integer again
  4. score_date – a date

Stuck? Here's a hint!

Type:

CREATE TABLE result (
  id integer,
  name varchar(32),
  score integer,
  score_date date
);