1. DDL
DDL
= Data Definition Languages
= 数据定义语言。
DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema.
SQL最常见的DDL有三个:
- CREATE
- DROP
- ALTER
CREATE
语法:
-
自定义字段名和各自的数据类型
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
…
columnN datatype,
PRIMARY KEY( one or more columns ) );
注意,PRIMARY KEY
后使用括号。
- 也可以从其他表格中取数据创建表格:
CREATE TABLE table_name SELECT 语句
,注意这里的SELECT语句
不能使用括号括起来。
2. DML
DML
= (Data Manipulation Language)
= 数据操纵语句,它包含了大部分的SQL语句。
The SQL commands that deals with the manipulation of data present in the database belong to DML or Data Manipulation Language and this includes most of the SQL statements. I
有四个最常见
- SELECT
- INSERT
- UPDATE
- DELETE
小结:简单来说DDL语言
的操作对象是数据库、是table,而占绝大多数的是DML语言
,它的操作对象可以理解为是table中的值。