Schema
一句话解释
Schema 是 blueprint 的数据库 — 它定义表, 列, 数据类型, constraints, and 关系.
用大白话说
schema 是the structure of a database。 It defines what tables exist, what columns each table has, the data types of those columns, the constraints (primary keys, foreign keys, etc.), and the relationships between tables.
The schema is the "shape" of the data. In a relational database, the schema is fixed — every row must conform to it. This is in contrast to NoSQL databases, which are "schemaless" (each document can have different fields).
Schemas can change over time through migrations — scripts that add, remove, or modify tables and columns. Managing schema changes is a critical part of database operations.
In some databases (like PostgreSQL), "Schema" also refers to a namespace within a database — a way to group related tables.
示例
-- This entire CREATE statement defines part of the schema
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
); CREATE TABLE 语句定义 Schema for 用户 表.
相关术语
相关资源
相关课程
- 数据库设计
学习如何 设计数据库 Schema.
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。