According to the docs, each PostgreSQL table is stored in a separate file. When a table exceeds 1 GB, it is divided into gigabyte-sized segments. (the same is more or less true for others rdbms )
Let's say I'm updating row which is located in the middle of the file. There is no way to write in the middle of the file without losing second part. If we split file into 2 part, write some data, second part of the file should by copied somewhere (in memory or into another file) and then appended to the first part of file. What rdbms does internally in this case ?
Maybe instead of modifying whole file rdbms append modified row with newer version to the file and keep old record unmodifed. If it's true, I have same questions about indexes. What if b-tree insertion occurs, index file must be modified in an arbitrary place of the file. Does rdbms rewrite whole index file on each update/insert ?