New answers tagged

0

After some digging, I managed to successfully copy history and trends from one item to another. The sort of syntax I used is this: History table: INSERT INTO history (`itemid`, `clock`, `value`, `ns`) SELECT '<new_itemid>', `clock`, `value`, `ns` FROM history WHERE itemid = <old_itemid>; Trends table: INSERT INTO trends (`itemid`, `clock`, `num`,...


1

Column < Row < Block < Table One column had a number, date, string, or a small number of other possibilities. It takes a few bytes or many bytes. One row like you described (4 columns each taking a few bytes) will take perhaps 40 bytes when you add in some overhead. One block is 16KB and holds (in your case) a few hundred rows. I mention a block ...


0

INSERT INTO new_table (id, ...) SELECT id + 1000, ... FROM old_table; This assumes the target table has ids no larger than 1000; adjust if needed.


3

You can use a data modifying common table expression: with deleted as ( DELETE FROM some_table WHERE id = 42 returning user_id ) INSERT INTO other_table(user_id, "timestamp") select user_id, timestamp '2020-01-04 21:32:34' from deleted;


Top 50 recent answers are included