MySQL之创建表
创建数据表
create table table_name (column_name column_type);
创建Author、Article、ArticleDetail三张表
#创建Author表
drop table if exists Author;
create table Author(
au_id int not null PRIMARY key auto_increment comment '主键',
name varchar(12) comment '姓名',
sex varchar(12),
address varchar(12),
qq varchar(12),
wechat varchar(25),
create_date datetime
)DEFAULT CHARSET=utf8;
#创建Article表
drop table if exists Article;
create table Article(
ar_id int not null PRIMARY key auto_increment comment '主键',
type varchar(12) comment '类型',
author varchar(12)comment '作者',
au_id int(11),
articles int(11),
qq_group int(11),
fans int(11),
update_date datetime
)DEFAULT CHARSET=utf8;
#创建ArticleDetail表
drop table if exists ArticleDetail;
create table ArticleDetail(
ad_id int not null PRIMARY key auto_increment comment '主键',
ar_id int(11),
title varchar(255) comment '文章标题',
url varchar(255)comment '链接',
reade_times int(11),
praise_times int(11),
comments_times int(11),
publish_date datetime,
FULLTEXT(url)
)DEFAULT CHARSET=utf8;
MySQL之操作表
表中增加新列
alter table table_name add column_name column_type;
Author表增加国籍(hometown)列
#在Author表后增加国籍列
alter table Author add hometown varchar(12);