Unanswered: How to make INSERT INTO begin in row 1?
I am using VB.NET with postgresql. I have created a table with one column (column1) and then I insert 10 values into column1. I then add another column (column2) and insert 10 values into column2. The rows that are filled in column1 are rows 1 through 11. The rows that are filled in column2 are rows 12 through 22. So rows 1 through 11 in column2 are empty.
Is there any way to make the column2 data insert begin in row 1?
I am trying to keep the table as small as possible and I don't want to have empty rows.
A row in a table, also known as a record, is a data instance that has some logical foundation. For example, in a table of people, a row could describe an individual person, including last name, first name, address, telephone number, etc. From your description, it seems you are storing unrelated values in the two table columns, and perhaps they should be in two tables instead. Nevertheless, here is an answer. PostgreSQL, like other databases, does not keep track of row numbers automatically. Storage is catch-as-catch-can, and things get pretty jumbled up when you insert, update, and delete rows from a table. To access a row, you need to identify it by some value, such as a key field. Also, the INSERT command does just what you describe - it adds a row. Try something like this
UPDATE table SET column2 = value WHERE column1 = value;