liveBook · Manning

Column

As explained in Learn SQL in a Month of Lunches

A column is a vertical set of table fields in which each position represents the same attribute across rows.

A column is a vertical grouping of one attribute across every row in a table. In a spreadsheet-like table, columns such as Title, Price, and Publication Date organize the same kind of information for each item. A column may also be called a field, although field is not an SQL term. section 2.1 section 2.4

Figure 2.2 The spreadsheet of book titles, with the Title column highlighted to show the vertical nature of columns

The highlighted Title column shows that a column runs vertically through a table, while each row supplies one value for it. section 2.1

Each row has a representation of every column, and each column position holds a value for that row. A table needs at least one column, but it can have no rows. Some column values may be absent when the table allows that absence; for example, not every person has a middle name. section 2.1 section 2.6

Select one column

To retrieve the Name values from every row of a vegetables table, name the column after SELECT and the table after FROM: SELECT Name FROM vegetables; Column names are commonly singular because each row usually contributes one value to that column. section 2.2

Columns also guide table design and data changes:

  • Choose clear, meaningful column names and data types when creating a table. Reusing a name across tables is most useful when similarly named columns have a relationship. section 18.1.1
  • Update values as properties represented by columns; an update can affect selected columns or columns across every row. section 17.1
  • Add a new column at the end of an existing table by default. Its display order can still be chosen in queries, and rearranging stored columns can require extra resources. section 18.2.2

Columns appear in data diagrams as the named, typed entries inside each table. Similar names such as OrderID and TitleID can help identify related data, while vague names such as ID or Name can become ambiguous in databases with many tables. section 18.1.1 section 18.4.1

How Learn SQL in a Month of Lunches covers it

How deep it goes
Defines vertical attributes through spreadsheet examples, then gives practical naming, missing-value, update, and addition considerations without storage internals.
Examples
Uses fictional book and vegetable tables, a middle-name field, category columns, and SELECT Name FROM vegetables.
What it assumes
Teaches columns from zero through a spreadsheet analogy and assumes only familiarity with basic spreadsheet terms.
What you can do after
Apply it via MySQL Workbench to select a named column and interpret returned values.
How it connects
Connects columns with tables, rows, values, SELECT, data types, primary keys, foreign keys, and data diagrams.

Also explained in

Compare how 9 books explain column →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn SQL in a Month of Lunches. The section links point to the parts of the book it draws on.