sqlite add tag
FoggyFinder
I have a tables, simplified version of which could look like it:

![tAQ2.jpg](/image?hash=4be306eba455b167b419a0cacf9794b48ad3c52db62f996847dbe516a7c4790d)
after a while I've realised that `SomeTable` table is missing one column - `number`.

I can alter table but default value has to be a constant.

```
ALTER TABLE SomeTable
ADD COLUMN number Integer NOT NULL DEFAULT 0;
```

I know there is [`ROW_NUMBER`](https://www.sqlitetutorial.net/sqlite-window-functions/sqlite-row_number/) function but I wasn't able to find good article/answer about how to apply it to data in a table.

To illustrate on a simple sample: 

Current state

| Id | Header  | Timestamp  | number | OtherId |
|----|---------|------------|--------|---------|
| 1  | Header1 | 17.11.2020 | 0      | 1       |
| 2  | Header2 | 18.11.2020 | 0      | 2       |
| 3  | Header3 | 19.11.2020 | 0      | 1       |

Desired output:

| Id | Header  | Timestamp  | number | OtherId |
|----|---------|------------|--------|---------|
| 1  | Header1 | 17.11.2020 | 1      | 1       |
| 2  | Header2 | 18.11.2020 | 1      | 2       |
| 3  | Header3 | 19.11.2020 | 2      | 1       |

Link to a fiddle:

https://dbfiddle.uk/?rdbms=sqlite_3.27&fiddle=e84fd8117a5ac483477eebd4c14f39f4
Top Answer
Jack Douglas
`row_number` does appear to be what you are looking for:

<>https://dbfiddle.uk/?rdbms=sqlite_3.27&fiddle=57d644b63aea67851c8b9eff5f8777c2&hide=511

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.