/**
*@author 胡晋滨
*@github
*@email 368199437@qq.com
*/
二维表的创建
目录
- MySQL创建数据库
- 使用数据库
- 删除数据库
- 创建表
- 添加数据
- 新增字段
1.MySQL创建数据库
create database 库名 default character set utf8;
2.使用数据库
use 库名;
3.删除数据库
use 库名;
4.创建表
create table 表名(
字段名 类型(约束) not null auto_increment primary key,##字段自动自增设置为主键
字段名 类型(约束)
...
)
##示例
create table student(
sid int(10) not null auto_increment primary key,
sname varchar(100) not null,
sage int(3) check (sage>0 and sage<150),
ssex char(4) check (ssex='男' or ssex='女'),
sbirth date
)
5.添加数据
insert into student values(DEFAULT,'sname',sage,'ssex','yyyy-MM-dd');
##示例
insert into student values(DEFAULT,'胡晋滨',25,'男','2020-03-27');
6.新增字段
alter table 表名 add 字段名 类型;
##示例
alter table student add money float;