Skip to content

Instantly share code, notes, and snippets.

@chriscarlsondev
Created July 1, 2019 04:33
Show Gist options
  • Save chriscarlsondev/db0ec03bc1ecca136f3d8b1a3cae272b to your computer and use it in GitHub Desktop.
Save chriscarlsondev/db0ec03bc1ecca136f3d8b1a3cae272b to your computer and use it in GitHub Desktop.
-- First, remove the table if it exists
drop table if exists bookmarks;
-- Create the table anew
create table bookmarks (
id INTEGER primary key generated by default as identity,
title VARCHAR(50) not null,
URL VARCHAR(50) not null,
description VARCHAR(300),
rating INTEGER not null
);
-- insert some test data
-- Using a multi-row insert statement here
insert into bookmarks (title, URL, description, rating)
values
('Google', 'http://www.google.com/','Search engine',5),
('Yahoo', 'https://www.yahoo.com','Unpopular search engine',2),
('CNN', 'http://www.cnn.com/','News web site',4),
('YouTube','http://www.youtube.com/','A place for videos',5),
('Facebook','http://www.facebook.com/','A social media platform',3),
('Wikipedia','http://www.wikipedia.org/','An encylopedia',5),
('Amazon','http://www.amazon.com/','An online retailer',2),
('Twitter','http:///www.twitter.com/','A social media platform for the birds',4),
('Reddit','http://www.reddit.com/','Online news and sharing site',3),
('Instagram','http://www.instagram.com/','A social media platform for photo sharing',5)
@chriscarlsondev
Copy link
Author

Execute these steps to create the database and run the script:

  1. psql -U dunder-mifflin
  2. CREATE DATABASE bookmarks;
  3. \c bookmarks;
  4. \i /path/bookmarks.sql;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment