-- 创建数据库
create database blog;
use blog;
-- 博客信息表
create table blog(
id int auto_increment not null,
title varchar(255),
author_id int,
publish_time datetime,
read_count int,
comment_count int,
content text,
type_id int,
primary key(id)
);
-- 用户表
create table user(
id int auto_increment not null,
account varchar(255),
password varchar(255),
name varchar(255),
avt varchar(255),
login_time datetime,
primary key(id)
);
-- 博客分类表
create table blog_type(
id int auto_increment not null,
type_name varchar(255),
remark varchar(255),
primary key(id)
);
-- 用户信息
insert into user (account,password,name,avt,login_time)
values('zhangsan','123456','张三',null,curdate());
insert into user (account,password,name,avt,login_time)
values('lisi','123456','李四',null,curdate());
insert into user (account,password,name,avt,login_time)
values('wangwu','123456','王五',null,curdate());
insert into user (account,password,name,avt,login_time)
values('maliu','123456','马六',null,curdate());
-- 初始化博客分类
insert into blog_type (type_name,remark) values('Java',null);
insert into blog_type (type_name,remark) values('Python',null);
insert into blog_type (type_name,remark) values('Ruby',null);
-- 初始化博客信息
insert into blog (title,author_id,publish_time,read_count,comment_count,content,type_id)
values('Java学习',1,sysdate(),0,0,'Java课程的基础学习',1);
insert into blog (title,author_id,publish_time,read_count,comment_count,content,type_id)
values('Python学习',2,sysdate(),0,0,'Python课程的基础学习',2);
insert into blog (title,author_id,publish_time,read_count,comment_count,content,type_id)
values('Ruby学习',3,sysdate(),0,0,'Ruby课程的基础学习',3);
insert into blog (title,author_id,publish_time,read_count,comment_count,content,type_id)
values('Java Web学习',4,sysdate(),0,0,'Java Web课程的基础学习',1);
0 回复
添加回复
请先登陆