A row in databases is a single record in a table that holds exactly one value, or NULL, for each column defined by the table’s schema. In relational databases, each row represents one instance of the entity the table describes, such as one customer, one order or one sensor reading. The terms record and tuple are common synonyms: “record” dominates in everyday engineering speech, while “tuple” comes from relational theory.
Rows are the unit that applications create, read, update and delete through CRUD operations, and they are the unit that a primary key identifies. How a database engine stores, locks and versions rows determines much of its performance and concurrency behavior.
What a row represents in the relational model
In the relational model defined by E. F. Codd, a table is a relation, and a row is a tuple: an ordered set of attribute values drawn from the domains of the relation’s columns. Formally, a relation is a set of tuples, which implies two properties that SQL relaxes in practice: rows have no inherent order, and no two rows are identical.
SQL tables are technically multisets (bags), so duplicate rows are allowed unless a primary key or unique constraint forbids them. Likewise, the order in which rows are returned is undefined without ORDER BY, even when a query appears to return them in insertion order on a small test table.
The table below maps the vocabulary used in different contexts to the same concept.
| Context | Term for a row | Term for a column |
|---|---|---|
| Relational theory | Tuple | Attribute |
| SQL databases | Row | Column |
| File processing | Record | Field |
| Spreadsheets | Row | Column |
| Document stores | Document | Field or key |
How a row is identified and constrained
A row is identified logically by its primary key, a column or combination of columns whose values are unique and not NULL across the table. Any column set that could serve this role is a candidate key; a key built from several columns is a composite key.
Database engines also maintain a physical row identifier, which points to the storage location. Physical identifiers can change when rows are moved, updated or reorganized, so applications should never treat them as stable keys.
| Identifier | Example | Stability |
|---|---|---|
| Primary key | customer_id = 4821 | Stable by design |
| Natural key | ISBN of a book | Stable while the real-world value stays fixed |
| PostgreSQL ctid | Block and item number | Changes after UPDATE or VACUUM FULL |
| Oracle ROWID | File, block and slot address | Can change after table moves |
| SQLite rowid | 64-bit integer | Stable unless the table is rebuilt |
Constraints act at row level as well. A CHECK constraint validates values within one row, a NOT NULL constraint forbids missing values in a column, and a foreign key requires that a referenced row exists in another table, which enforces referential integrity.
How database engines store rows
Most transactional engines store rows in fixed-size pages, typically 4 KB, 8 KB or 16 KB, each containing a header, a slot directory and the row data itself. Each stored row carries a row header with metadata such as length, NULL bitmap and, in multiversion systems, transaction visibility information.
Under multiversion concurrency control (MVCC), an UPDATE often writes a new row version instead of overwriting the old one. Readers see the version that was valid when their snapshot began, and obsolete versions are later removed by background processes such as VACUUM in PostgreSQL or the purge thread in MySQL InnoDB.
Storage layout also distinguishes row-oriented from column-oriented engines, as the following comparison shows.
| Property | Row-oriented storage | Column-oriented storage |
|---|---|---|
| Physical layout | All values of a row together | All values of a column together |
| Best workload | OLTP with many small reads and writes | Analytics scanning few columns |
| Insert of one row | One contiguous write | One write per column segment |
| Compression | Moderate | High, because similar values sit together |
| Typical engines | PostgreSQL, MySQL InnoDB | ClickHouse, columnar warehouses |
Very wide values, such as long text or binary objects, may be stored outside the main row in overflow pages; PostgreSQL calls this mechanism TOAST. The row then keeps only a pointer, which keeps pages compact and scans efficient.
Working with rows in SQL
SQL manipulates rows through four core statements: INSERT adds rows, SELECT reads them, UPDATE changes column values in matching rows, and DELETE removes them. Each statement operates on a set of rows defined by a WHERE clause, not on a single row unless the predicate narrows it to one.
- Row-level locking lets concurrent transactions modify different rows of the same table without blocking each other.
- Row-level triggers fire once for each affected row, unlike statement-level triggers that fire once per statement.
- Row value constructors such as (a, b) = (1, 2) compare several columns in one expression and support keyset pagination.
- Row-level security policies filter which rows a given user may see or modify.
A database cursor processes a result set row by row, which is useful for procedural logic but usually far slower than an equivalent set-based statement.
Common mistakes when reasoning about rows
Many defects in database code come from incorrect assumptions about rows, especially about order, uniqueness and size. The table below lists frequent errors and their corrections.
| Mistake | Consequence | Fix |
|---|---|---|
| Relying on insertion order | Results change after maintenance or parallel plans | Always specify ORDER BY |
| Tables without a primary key | Duplicate rows and ambiguous updates | Define a primary key on every table |
| Selecting all columns | Wider rows transferred and fewer index-only scans | List only needed columns |
| Processing rows in loops | Thousands of round trips | Use set-based statements |
| Storing physical row IDs | Broken references after reorganization | Reference the logical key |
Row width deserves attention too. Engines impose maximum row sizes, for example about 65,535 bytes for the in-row portion in MySQL, and wide rows reduce how many fit on a page, which increases I/O for every scan.
Put simply
A row is one line in a data table. Picture a sheet listing all the members of a club. Each row is one member. The columns are the details about them, such as name, phone number and joining date.
Every row should be uniquely recognizable, usually through an ID number. That way the database never confuses two members with the same name. When an app adds, changes or removes information, it works with one or more rows.
In practice
An online bookstore stores its orders in an orders table, where each row is one order with columns for order_id, customer_id, order date, status and total amount. When a customer checks out, the application inserts one row into orders and several rows into an order_items table, one row per book, all inside a single transaction.
During a busy promotion, a developer notices that the nightly report lists orders in a different sequence each run. The cause is a query without ORDER BY that started using a parallel scan. Adding ORDER BY order_date, order_id fixes the report, and adding a composite index on those columns keeps it fast across about two million rows.