zoukankan      html  css  js  c++  java
  • MySQL的存储引擎(二)解决Warning Code : 3719 'utf8' is currently an alias for the character set UTF8MB3,...

    1.外键约束:MySQL支持外键的常用存储引擎只有InnoDB,在创建外键的时候,要求父表必须有对应的索引,子表在创建外键的时候也会自动创建对应的索引。

    CREATE TABLE country(
        country_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
        country VARCHAR(50) NOT NULL,
        last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        PRIMARY KEY (country_id)
    ) ENGINE=INNODB DEFAULT CHARSET=utf8;
    
    CREATE TABLE city (
        city_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
        city VARCHAR(50) NOT NULL,
        country_id SMALLINT UNSIGNED NOT NULL,
        last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        PRIMARY KEY (city_id),
        KEY idx_fk_country_id (country_id),
        CONSTRAINT fk_city_country FOREIGN KEY (country_id) REFERENCES country (country_id) ON DELETE RESTRICT ON UPDATE CASCADE 
    ) ENGINE=INNODB DEFAULT CHARSET=utf8;

     1 warnings:

    Warning Code : 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.

    查看下mysql字符集

     SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';

    修改默认字符集例句:
    CREATE
    DATABASE IF NOT EXISTS database_name DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci
    CREATE TABLE city1 (
        city_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
        city VARCHAR(50) NOT NULL,
        country_id SMALLINT UNSIGNED NOT NULL,
        last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        PRIMARY KEY (city_id),
        KEY idx_fk_country_id (country_id),
        CONSTRAINT fk_city_country FOREIGN KEY (country_id) REFERENCES country (country_id) ON DELETE RESTRICT ON UPDATE CASCADE 
    ) ENGINE=INNODB DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci

    不再报错:

     

  • 相关阅读:
    python基础集结号
    3,jieba gensim 最好别分家之最简单的相似度实现
    2,PyAudio 实现录音 自动化交互实现问答
    1,百度云接口
    16,Flask-Migrate
    移动端web开发 尽量哪些标签 常用标签及注意事项
    flex布局
    -webkit-box
    网页图片jpg,gif,png对比。
    原生判断是否存在某个类,手机端事件,手机端测试
  • 原文地址:https://www.cnblogs.com/kate7/p/13299006.html
Copyright © 2011-2022 走看看