数据定义语言 Data Definition Language (DDL)
creation, dropping, and altering tables
数据的结构会被改变
创建
CREATE TABLE students (
ID INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
city VARCHAR(100)
);
删除
drop 和 delete的区别
DROP TABLE xx and DELETE FROM xx
一个是对table的操作, 一个数对数据的操作, 对数据的操作都有from
添加
添加列
ALTER TABLE students
ADD country VARCHAR(30);
删除一列
ALTER TABLE students
DROP COLUMN country;
删除多列
ALTER TABLE students
DROP ( city, country );
data manipulation language (DML)
insert, select, delete, update
改变数据本身
插入
INSERT INTO students (ID, name, city)
VALUES (4, 'John', 'Dresden')
删除
DELETE FROM students
WHERE city='Berlin';
更新
UPDATE students
SET city='Berlin'
WHERE ID=4;
data control language (DCL)
grant, revoke
定义访问权限
transaction control language(TCL)
commit,rollback
用于通过DML管理更改