Skip to content

Creating tables · ⁨创建表⁩

English

Two kinds of SQL command

SQL has two halves:

  • DDL (Data Definition Language) changes the structure — the tables themselves.
  • DML (Data Manipulation Language) works with the data inside the tables — reading it with SELECT, and adding, changing, or removing it with INSERT/UPDATE/DELETE. Everything so far (SELECT) is DML.

CREATE TABLE is the main DDL command. It lists each column with a data type and marks the primary key:

中文

两类 SQL 命令

SQL 分为两半:

  • DDL(数据定义语言)改变结构 —— 也就是表本身。
  • DML(数据操纵语言)处理表里的数据 —— 用 SELECT 读取,用 INSERT/UPDATE/DELETE 增加、修改或删除。到目前为止学的(SELECT)都是 DML。

CREATE TABLE 是主要的 DDL 命令。它列出每一列及其数据类型,并标出主键:

CREATE TABLE customer (
  id   INTEGER PRIMARY KEY,
  name VARCHAR(20),
  city VARCHAR(15)
);

CREATE TABLE 定义各列,并建立一张空表

Handout

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩