Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以把配套的sql放上来吗? #7

Open
Pissssofshit opened this issue Oct 28, 2020 · 2 comments
Open

可以把配套的sql放上来吗? #7

Pissssofshit opened this issue Oct 28, 2020 · 2 comments

Comments

@Pissssofshit
Copy link

在知乎买的书,里面的sql竟然是图片截图...

@Joseph516
Copy link

Joseph516 commented Feb 2, 2021

# 部分sql代码
CREATE DATABASE
    IF
    NOT EXISTS blog_service DEFAULT CHARACTER
    SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;

# 创建标签表
CREATE TABLE `blog_tag`
(
    `id`              int(10) unsigned NOT NULL AUTO_INCREMENT,
    `name`           varchar(100)        DEFAULT '' COMMENT '标签名称',
    ## 公共字段 ##
    `created_on`      int(10) unsigned    DEFAULT '0' COMMENT '创建时间',
    `created_by`      varchar(100)        DEFAULT '' COMMENT '创建人',
    `modified_on`     int(10) unsigned    DEFAULT '0' COMMENT '修改时间',
    `modified_by`     varchar(100)        DEFAULT '' COMMENT '修改人',
    `deleted_on`      int(10) unsigned    DEFAULT '0' COMMENT '删除时间',
    `is_del`          tinyint(3) unsigned DEFAULT '1' COMMENT '是否删除,0为未删除,1为删除',
    ## 公共字段 ##
    `state`           tinyint(3) unsigned DEFAULT '1' COMMENT '状态0为禁用,状态1为启用',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='标签管理';

# 创建文章表
CREATE TABLE `blog_article`
(
    `id`              int(10) unsigned NOT NULL AUTO_INCREMENT,
    `title`           varchar(100)        DEFAULT '' COMMENT '文章标题',
    `desc`            varchar(255)        DEFAULT '' COMMENT '文章简述',
    `cover_image_url` varchar(255)        DEFAULT '' COMMENT '封面图片地址',
    `content`         longtext COMMENT '文章内容',
    ## 公共字段 ##
    `created_on`      int(10) unsigned    DEFAULT '0' COMMENT '创建时间',
    `created_by`      varchar(100)        DEFAULT '' COMMENT '创建人',
    `modified_on`     int(10) unsigned    DEFAULT '0' COMMENT '修改时间',
    `modified_by`     varchar(100)        DEFAULT '' COMMENT '修改人',
    `deleted_on`      int(10) unsigned    DEFAULT '0' COMMENT '删除时间',
    `is_del`          tinyint(3) unsigned DEFAULT '1' COMMENT '是否删除,0为未删除,1为删除',
    ## 公共字段 ##
    `state`           tinyint(3) unsigned DEFAULT '1' COMMENT '状态0为禁用,状态1为启用',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='文章管理';

# 创建文章标题关联表
CREATE TABLE `blog_article_tag`
(
    `id`         int(10) unsigned NOT NULL AUTO_INCREMENT,
    `article_id` int(11)          NOT NULL COMMENT '文章ID',
    `tag_id`     int(10) unsigned NOT NULL DEFAULT '0' COMMENT '标签ID',
    ## 公共字段 ##
    `created_on`      int(10) unsigned    DEFAULT '0' COMMENT '创建时间',
    `created_by`      varchar(100)        DEFAULT '' COMMENT '创建人',
    `modified_on`     int(10) unsigned    DEFAULT '0' COMMENT '修改时间',
    `modified_by`     varchar(100)        DEFAULT '' COMMENT '修改人',
    `deleted_on`      int(10) unsigned    DEFAULT '0' COMMENT '删除时间',
    `is_del`          tinyint(3) unsigned DEFAULT '1' COMMENT '是否删除,0为未删除,1为删除',
    ## 公共字段 ##
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4 COMMENT ='文章标签关联';

# JWT
CREATE TABLE `blog_auth`
(
    `id`         int(10) unsigned NOT NULL AUTO_INCREMENT,
    `app_key`    varchar(20) DEFAULT '' COMMENT 'Key',
    `app_secret` varchar(50) DEFAULT '' COMMENT 'Secret',
    ## 公共字段 ##
    `created_on`  int(10) unsigned          DEFAULT '0' COMMENT '创建时间',
    `created_by`  varchar(100)              DEFAULT '' COMMENT '创建人',
    `modified_on` int(10) unsigned          DEFAULT '0' COMMENT '修改时间',
    `modified_by` varchar(100)              DEFAULT '' COMMENT '修改人',
    `deleted_on`  int(10) unsigned          DEFAULT '0' COMMENT '删除时间',
    `is_del`      tinyint(3) unsigned       DEFAULT '1' COMMENT '是否删除,0为未删除,1为删除',
    ## 公共字段 ##
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '认证管理';

INSERT INTO `blog_service`.blog_auth (`id`, `app_key`, `app_secret`, `created_on`, `created_by`, `modified_on`,
                                      `modified_by`, `deleted_on`,
                                      `is_del`) VALUE (1, 'eddycjy', 'go-programming-tour-book', 0, 'eddycjy', 0, '', 0, 0);

@MiracleWong
Copy link

这里有个问题,希望后面的同学遇到时,可以处理。
@Joseph516 给出的blog_article 的建表语句中,desc没有加backquote反引号(这个书上是有的,其实是加了的,应该GitHub的Markdown显示的问题,默认把backquote当做Markdown的Code 格式了),加上就好了,否则会报错,因为descMySQL 关键词冲突了。
依然感谢 @Joseph516 给出SQL 语句。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants