Write a set of SQL statements together to:
- create a new table
courses
with the following columns, data types and constraints.
column | data type | constraint |
---|
id | INTEGER | UNIQUE, NOT NULL |
---|
name | TEXT | UNIQUE, NOT NULL |
---|
abbreviation | TEXT | Length should not be more than 3 characters |
---|
type | TEXT | Should be either 'Language' or 'Framework' |
---|
- add these record rows to the created table
courses
id (INTEGER) | name (TEXT) | abbreviation (TEXT) | type (TEXT) |
---|
1 | Ruby | rb | Language |
2 | Rails | rls | Framework |
Hint:
-
To ensure a column name
should have values which are of length less than a value n
, simply include the expression LENGTH(name) < n
in the CHECK constraint.
-
To ensure a column name
contains values which are either a
, b
or c
, simply include the expression name IN ('a', 'b', 'c')
in the CHECK constraint.