· 6 years ago · Apr 18, 2019, 10:40 AM
1drop table if exists bookmarks;
2
3-- Create the table anew
4create table bookmarks (
5 id INTEGER primary key generated by default as identity,
6 name text not null,
7 url text not null,
8 description text,
9 rating INTEGER
10);
11
12ALTER TABLE bookmarks
13 ADD CONSTRAINT rating_range
14 CHECK (rating > 0 AND rating < 6);
15
16
17 INSERT INTO bookmarks
18 (name, url, description, rating)
19 VALUES (
20 'bookmark1','google.com','test', 4),
21 (
22 'bookmark2','google.com','test', null),
23 (
24 'bookmark3','reddit.com','test', null),
25 (
26 'bookmark4','digg.com',null, null),
27 (
28 'bookmark5','espn.com','test', 3),
29 (
30 'bookmark6','fox.com','test', 2),
31 (
32 'bookmark7','yahoo.com','test', 1),
33 (
34 'bookmark8','bing.com','test', 2),
35 (
36 'bookmark9','wikipedia.com','test', 4),
37 ('bookmark10','mozilla.com','test', 4);