Skip to content

Instantly share code, notes, and snippets.

@thebinarypenguin
Created February 25, 2019 21:01
Show Gist options
  • Save thebinarypenguin/5e062308660dcafb66662f2ec08c84b0 to your computer and use it in GitHub Desktop.
Save thebinarypenguin/5e062308660dcafb66662f2ec08c84b0 to your computer and use it in GitHub Desktop.
What is the postgres version of USE?
CREATE ROLE dunder_mifflin_admin;
CREATE DATABASE bookmarks OWNER dunder_mifflin_admin;
-- USE bookmarks ---
CREATE TABLE bookmarks (
id INTEGER primary key generated by default as identity,
title text NOT NULL,
url text NOT NULL,
description text,
rating INTEGER CHECK(rating >= 1 AND rating <= 5)
);
-- Full Bookmarks --
INSERT INTO bookmarks (title, url, description, rating) VALUES('Site Alpha', 'http://example.com', 'Alpha Alpha Alpha', 1);
INSERT INTO bookmarks (title, url, description, rating) VALUES('Site Bravo', 'http://example.com', 'Bravo Bravo Bravo', 2);
INSERT INTO bookmarks (title, url, description, rating) VALUES('Site Charlie', 'http://example.com', 'Charlie Charlie Charlie', 3);
INSERT INTO bookmarks (title, url, description, rating) VALUES('Site Delta', 'http://example.com', 'Delta Delta Delta', 4);
INSERT INTO bookmarks (title, url, description, rating) VALUES('Site Echo', 'http://example.com', 'Echo Echo Echo', 5);
-- Bookmarks Without Ratings ---
INSERT INTO bookmarks (title, url, description) VALUES('Site Foxtrot', 'http://example.com', 'Foxtrot Foxtrot Foxtrot');
INSERT INTO bookmarks (title, url, description) VALUES('Site Golf', 'http://example.com', 'Golf Golf Golf');
INSERT INTO bookmarks (title, url, description) VALUES('Site Hotel', 'http://example.com', 'Hotel Hotel Hotel');
INSERT INTO bookmarks (title, url, description) VALUES('Site India', 'http://example.com', 'India India India');
INSERT INTO bookmarks (title, url, description) VALUES('Site Juliet', 'http://example.com', 'Juliet Juliet Juliet');
-- Bookmarks Without Descriptions --
INSERT INTO bookmarks (title, url, rating) VALUES('Site Kilo', 'http://example.com', 1);
INSERT INTO bookmarks (title, url, rating) VALUES('Site Lima', 'http://example.com', 2);
INSERT INTO bookmarks (title, url, rating) VALUES('Site Mike', 'http://example.com', 3);
INSERT INTO bookmarks (title, url, rating) VALUES('Site November', 'http://example.com', 4);
INSERT INTO bookmarks (title, url, rating) VALUES('Site Oscar', 'http://example.com', 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment