创建数据库及数据表的基本语法

以创建一张Person表为例


# 创建数据库
create database if not exists daily;

# 创建数据表
create table if not exists `person` (
    `id` int unsigned auto_increment,
    `name` varchar(20) not null,
    `age` int unsigned not null,
    `gender` varchar(5) not null,
    `birthday` DATE DEFAULT NULL,
    primary key(`id`)
)ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

# 插入数据
insert into `person` values
(null,'Rick',12,'男','2020-07-15'),
(null,'Morty',55,'男','1988-03-17'),
(null,'Beth',28,'女','1999-12-05'),
(null,'Jerry',30,'男','1990-05-11'),
(null,'Summer',14,'女','2018-03-12'),
(null,'Bird',29,'男','1989-04-16');

posted @ 2020-07-01 11:02  juyss  阅读(970)  评论(0编辑  收藏  举报