Last active
November 7, 2022 13:45
-
-
Save waltton/29dc569b61b407b1c12d5b741aa5b764 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create our product table, very simple, there's not much to it | |
CREATE TABLE product ( | |
id UUID DEFAULT gen_random_uuid() PRIMARY KEY, | |
name TEXT, | |
price NUMERIC, | |
date_added TIMESTAMP(0) WITH TIME ZONE DEFAULT NOW(), | |
date_updated TIMESTAMP(0) WITH TIME ZONE DEFAULT NOW() | |
); | |
-- And we can fill it up with some very important items, cat toys | |
INSERT INTO product(name, price) | |
VALUES ('feather on the stick', 10.00) | |
, ('mouse on the stick', 12.00) | |
, ('bed cavern', 139.00) | |
, ('scratch toy', 29.00) | |
, ('loud bell ball', 8.00); | |
SELECT substring(id::text, 1, 5) || '...' AS id, name, to_char(price, '999D99') AS price, '... ' || substring(date_added::text, 12, 8) AS date_added, '... ' || substring(date_updated::text, 12, 8) AS date_updated FROM product; | |
-- id | name | price | date_added | date_updated | |
-- ----------+----------------------+---------+--------------+-------------- | |
-- 3da19... | feather on the stick | 10.00 | ... 16:53:59 | ... 16:53:59 | |
-- 156a6... | mouse on the stick | 12.00 | ... 16:53:59 | ... 16:53:59 | |
-- 4ad03... | bed cavern | 139.00 | ... 16:53:59 | ... 16:53:59 | |
-- 1612f... | scratch toy | 29.00 | ... 16:53:59 | ... 16:53:59 | |
-- b9803... | loud bell ball | 8.00 | ... 16:53:59 | ... 16:53:59 | |
-- (5 rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment