MySQL入门 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

create创建数据库表


创建数据库表太常用了,只要用到数据库,我们就会用到创建数据库表,我们用create 语句来创建,看下面语法:

create table tbl_name(create_definition,...) [type =table_type] 
create_definition:col_name type [not null | null][default default_value] [auto_increment][primary_key]

create table是固定的关键字,后面紧跟要创建的表的名称,括号里面是字段的内容,内容可选有:是否为空,是否有默认值,是否为主键,是否自增长等等,例如:

create table test01_02(id varchar(50) not null auto_increment primary key,
name nvarchar(40) null default "002",
age int(5)null default 444);
先选用test01数据库,然后创建一个名为test01_01的数据表,字段分别name(varchar),age(int),address(varchar)