Skip to content

列

一句话解释

列是 named 字段 in 表那个存储 one 特定类型的 数据 (文本, 数字, date) for 每个行.

用大白话说

列是 vertical slice 的表. 它有 name and 数据类型 — 例如, email (文本), age (integer), created_at (timestamp). Every row in the table has a value (or NULL) for that column, and every value must match the column's type.

Columns define the structure of your data. When you create a table, you declare its columns and their types. This is the "Schema" — the contract that every row must follow.

You can also add constraints to columns: NOT NULL (must have a value), UNIQUE (no duplicates), DEFAULT (a value if none is provided).

示例

sql
CREATE TABLE users (
  id         SERIAL PRIMARY KEY,
  email      TEXT UNIQUE NOT NULL,
  age        INTEGER CHECK (age >= 0),
  created_at TIMESTAMP DEFAULT NOW()
);

Four 列, 每个使用类型 and constraints — UNIQUE, CHECK, and DEFAULT enforce 规则.

相关术语

相关资源

相关课程

  • Constraints

    学习如何列 constraints enforce 数据规则.

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表