-1

I have table in RDS which consists two columns id and user activity at some time exactly values active/away.I get user activity every day so I need to add user activity column every day to that table.Any ideas how to do it?Now I have table with first two columns in RDS,but I am in stuck with how to add columns to that table

+-------------+------------+------------+
| id          | 2020-08-13 | 2020-08-14 |
-----------------------------------------
| 12345       | active     | away       |

1 Answers1

2

You could use an alter table ... add column, but this is not the right way to solve the problem.

In a relational database, you add additional rows for repeated data, not additional columns. So your table should look like this:

+-------------+-------------+------------+
| id          | status_date | status     |
------------------------------------------
| 12345       | 2020-08-13  | active     |
| 12345       | 2020-08-14  | away       |

Then you add a new row using an insert.

Parsifal
  • 3,928
  • 5
  • 9