Skip to content

Instantly share code, notes, and snippets.

@waltton
Last active November 7, 2022 13:44
Show Gist options
  • Select an option

  • Save waltton/fe064d3fd2ddd05980ab72e8a106ca97 to your computer and use it in GitHub Desktop.

Select an option

Save waltton/fe064d3fd2ddd05980ab72e8a106ca97 to your computer and use it in GitHub Desktop.

Revisions

  1. waltton revised this gist Nov 7, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions update-increase10perc.sql
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,8 @@ SET price = price * 1.1
    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 in the stick | 11.00 | ... 16:53:59 | ... 16:54:00
    -- 156a6... | mouse in the stick | 13.20 | ... 16:53:59 | ... 16:54:00
    -- 3da19... | feather on the stick | 11.00 | ... 16:53:59 | ... 16:54:00
    -- 156a6... | mouse on the stick | 13.20 | ... 16:53:59 | ... 16:54:00
    -- 4ad03... | bed cavern | 152.90 | ... 16:53:59 | ... 16:54:00
    -- 1612f... | scratch toy | 31.90 | ... 16:53:59 | ... 16:54:00
    -- b9803... | loud bell ball | 8.80 | ... 16:53:59 | ... 16:54:00
  2. waltton revised this gist Nov 5, 2022. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions update-increase10perc.sql
    Original file line number Diff line number Diff line change
    @@ -7,12 +7,12 @@ UPDATE product
    SET price = price * 1.1
    , date_updated = NOW();

    SELECT substring(id::text, 1, 5) || '...' AS id, name, price, '... ' || substring(date_added::text, 12, 8), '... ' || substring(date_updated::text, 12, 8) FROM product;
    -- id | name | price | date_added | date_updated
    -- ----------+----------------------+---------+-----------------+----------------
    -- 358be... | feather in the stick | 11.000 | ... 18:07:31+04 | ... 18:07:32+04
    -- fb156... | mouse in the stick | 13.200 | ... 18:07:31+04 | ... 18:07:32+04
    -- e5f92... | bed cavern | 152.900 | ... 18:07:31+04 | ... 18:07:32+04
    -- e6f56... | scratch toy | 31.900 | ... 18:07:31+04 | ... 18:07:32+04
    -- b1e36... | loud bell ball | 8.800 | ... 18:07:31+04 | ... 18:07:32+04
    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 in the stick | 11.00 | ... 16:53:59 | ... 16:54:00
    -- 156a6... | mouse in the stick | 13.20 | ... 16:53:59 | ... 16:54:00
    -- 4ad03... | bed cavern | 152.90 | ... 16:53:59 | ... 16:54:00
    -- 1612f... | scratch toy | 31.90 | ... 16:53:59 | ... 16:54:00
    -- b9803... | loud bell ball | 8.80 | ... 16:53:59 | ... 16:54:00
    -- (5 rows)
  3. waltton revised this gist Nov 5, 2022. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions update-increase10perc.sql
    Original file line number Diff line number Diff line change
    @@ -7,12 +7,12 @@ UPDATE product
    SET price = price * 1.1
    , date_updated = NOW();

    SELECT substring(id::text from 1 for 5) || '...' AS id, name, price, date_added, date_updated FROM product;
    -- id | name | price | date_added | date_updated
    -- ----------+----------------------+---------+------------------------+------------------------
    -- 358be... | feather in the stick | 11.000 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- fb156... | mouse in the stick | 13.200 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- e5f92... | bed cavern | 152.900 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- e6f56... | scratch toy | 31.900 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- b1e36... | loud bell ball | 8.800 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    SELECT substring(id::text, 1, 5) || '...' AS id, name, price, '... ' || substring(date_added::text, 12, 8), '... ' || substring(date_updated::text, 12, 8) FROM product;
    -- id | name | price | date_added | date_updated
    -- ----------+----------------------+---------+-----------------+----------------
    -- 358be... | feather in the stick | 11.000 | ... 18:07:31+04 | ... 18:07:32+04
    -- fb156... | mouse in the stick | 13.200 | ... 18:07:31+04 | ... 18:07:32+04
    -- e5f92... | bed cavern | 152.900 | ... 18:07:31+04 | ... 18:07:32+04
    -- e6f56... | scratch toy | 31.900 | ... 18:07:31+04 | ... 18:07:32+04
    -- b1e36... | loud bell ball | 8.800 | ... 18:07:31+04 | ... 18:07:32+04
    -- (5 rows)
  4. waltton revised this gist Nov 5, 2022. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions update-increase10perc.sql
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,11 @@ SET price = price * 1.1
    , date_updated = NOW();

    SELECT substring(id::text from 1 for 5) || '...' AS id, name, price, date_added, date_updated FROM product;
    -- id | name | price | date_added | date_updated
    -- ----------+----------------------------------+---------+------------------------+------------------------
    -- 358be... | feather in the stick | 11.000 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- fb156... | mouse in the stick | 13.200 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- e5f92... | bed cavern | 152.900 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- e6f56... | scratch toy with loud bell balls | 31.900 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- b1e36... | just stand-alone loud bell ball | 8.800 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- id | name | price | date_added | date_updated
    -- ----------+----------------------+---------+------------------------+------------------------
    -- 358be... | feather in the stick | 11.000 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- fb156... | mouse in the stick | 13.200 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- e5f92... | bed cavern | 152.900 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- e6f56... | scratch toy | 31.900 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- b1e36... | loud bell ball | 8.800 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- (5 rows)
  5. waltton revised this gist Nov 4, 2022. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions update-increase10perc.sql
    Original file line number Diff line number Diff line change
    @@ -7,12 +7,12 @@ UPDATE product
    SET price = price * 1.1
    , date_updated = NOW();

    TABLE product;
    -- id | name | price | date_added | date_updated
    -- --------------------------------------+----------------------------------+---------+------------------------+------------------------
    -- 2ed5c1de-6610-4e96-b162-b64b0475f004 | feather in the stick | 11.000 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- e361a07d-6145-4a0e-8d6c-fb2df3c3a95c | mouse in the stick | 13.200 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- 7db846db-8ad2-4b8d-91d8-4e2c4bd66a88 | bed cavern | 152.900 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- 1ffaa602-21f4-436a-ab16-b3d5320ad247 | scratch toy with loud bell balls | 31.900 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- def0e027-fc11-4ec4-9770-f47140d6d246 | just stand-alone loud bell ball | 8.800 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- (5 rows)
    SELECT substring(id::text from 1 for 5) || '...' AS id, name, price, date_added, date_updated FROM product;
    -- id | name | price | date_added | date_updated
    -- ----------+----------------------------------+---------+------------------------+------------------------
    -- 358be... | feather in the stick | 11.000 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- fb156... | mouse in the stick | 13.200 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- e5f92... | bed cavern | 152.900 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- e6f56... | scratch toy with loud bell balls | 31.900 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- b1e36... | just stand-alone loud bell ball | 8.800 | 2022-11-04 18:07:31+04 | 2022-11-04 18:07:32+04
    -- (5 rows)
  6. waltton revised this gist Nov 4, 2022. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions update-increase10perc.sql
    Original file line number Diff line number Diff line change
    @@ -2,12 +2,11 @@
    SELECT pg_sleep(1);

    -- I started to think about it again, cat owners will pay anything to make their cats happy
    -- So lets make this at least 10% more expensive
    -- So let's make this at least 10% more expensive
    UPDATE product
    SET price = price * 1.1
    , date_updated = NOW();

    -- let's take a look at the product
    TABLE product;
    -- id | name | price | date_added | date_updated
    -- --------------------------------------+----------------------------------+---------+------------------------+------------------------
    @@ -16,4 +15,4 @@ TABLE product;
    -- 7db846db-8ad2-4b8d-91d8-4e2c4bd66a88 | bed cavern | 152.900 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- 1ffaa602-21f4-436a-ab16-b3d5320ad247 | scratch toy with loud bell balls | 31.900 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- def0e027-fc11-4ec4-9770-f47140d6d246 | just stand-alone loud bell ball | 8.800 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- (5 rows)
    -- (5 rows)
  7. waltton revised this gist Nov 4, 2022. 1 changed file with 13 additions and 2 deletions.
    15 changes: 13 additions & 2 deletions update-increase10perc.sql
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,19 @@
    -- After a while
    -- after a while
    SELECT pg_sleep(1);

    -- I started to think about it again, cat owners will pay anything to make their cats happy
    -- So lets make this at least 10% more expensive
    UPDATE product
    SET price = price * 1.1
    , date_updated = NOW();
    , date_updated = NOW();

    -- let's take a look at the product
    TABLE product;
    -- id | name | price | date_added | date_updated
    -- --------------------------------------+----------------------------------+---------+------------------------+------------------------
    -- 2ed5c1de-6610-4e96-b162-b64b0475f004 | feather in the stick | 11.000 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- e361a07d-6145-4a0e-8d6c-fb2df3c3a95c | mouse in the stick | 13.200 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- 7db846db-8ad2-4b8d-91d8-4e2c4bd66a88 | bed cavern | 152.900 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- 1ffaa602-21f4-436a-ab16-b3d5320ad247 | scratch toy with loud bell balls | 31.900 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- def0e027-fc11-4ec4-9770-f47140d6d246 | just stand-alone loud bell ball | 8.800 | 2022-11-04 18:00:09+04 | 2022-11-04 18:00:10+04
    -- (5 rows)
  8. waltton created this gist Nov 4, 2022.
    8 changes: 8 additions & 0 deletions update-increase10perc.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    -- After a while
    SELECT pg_sleep(1);

    -- I started to think about it again, cat owners will pay anything to make their cats happy
    -- So lets make this at least 10% more expensive
    UPDATE product
    SET price = price * 1.1
    , date_updated = NOW();