A database column is a named field that stores one attribute of every row in a table. Its definition includes a data type and may include rules that control which values are allowed. section 8.2.1 section 8.2.4
When designing a table, decide what each column represents and how its values should behave:
- Use a clear name such as username, author, or created_at to identify the stored attribute. section 8.2.4
- Choose a data type, such as VARCHAR for variable-length text, and optionally set a length limit such as VARCHAR(100). section 8.2.4
- Add constraints when the column has a special role: PRIMARY KEY uniquely identifies rows, while a foreign key connects a value to another table. section 8.2.4
A users table
A users table can define username as VARCHAR(100) PRIMARY KEY and password_hash as VARCHAR(128). Each row then stores one user, with username required to be unique. section 8.2.4
CREATE TABLE users (
username VARCHAR(100) PRIMARY KEY,
password_hash VARCHAR(128)
);
This CREATE TABLE statement shows column names, a VARCHAR type with a length limit, and a primary-key constraint together. section 8.2.4
Columns organize persistent database data: rows represent entries, while columns describe their attributes. SQL uses these definitions when creating, storing, and querying table data. section 8.2.1 section 8.2.4








