表
一句话解释
表是 结构 in relational 数据库那个持有数据 in 行 and 列 — 如 spreadsheet 使用 strict 规则.
用大白话说
table 是the fundamental storage unit in a relational database。 It has a name, a set of columns (each with a data type), and zero or more rows of data. Each column defines what kind of data it holds — text, numbers, dates, booleans.
想象一个 table as a very strict spreadsheet. Every row must have a value (or NULL) for every column, and every value must match the column's data type. You cannot put text into an integer column.
例如, a products table might have columns id (integer), name (text), price (numeric), and in_stock (boolean). Each row represents one product.
示例
sql
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
price NUMERIC(10, 2) NOT NULL,
in_stock BOOLEAN DEFAULT TRUE
);
INSERT INTO products (name, price) VALUES ('Widget', 9.99);这个创建 products 表使用 four 列 and inserts one 行.
相关术语
相关资源
相关课程
- 表
学习如何 创建 and manage 表.
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。