Mariadb数据库小结

1. 准备:

  安装好Mariadb,最新的版本是10.2,下载地址:https://downloads.mariadb.org/

2. 基础知识:

  2.1 数据库的连接:

       mysql -h xxx -u xxx -p 

      -h 本地主机

      -u 用户名

      -p 密码

   2.2 库级操作:

    2.2.1 显示数据库:"show databases;"

    2.2.2 选择数据库:"use dbname;"

    2.2.3 创建数据库:"create database dbname charset utf8;"

    2.2.4 删除数据库:"drop database dbname;"

  2.3 表级操作:

    2.3.1 显示库下的表:"show tables;"

    2.3.2 查看表结构:  "desc tablename;"

    2.3.3 查看表的创建过程: "show create table tablename;" 或者 "show create table tablename G"

    2.3.4 创建表:

        create table if not exists tablename (

          列名称1  列类型  [列参数]  [not null default],

          ......

        )engine=innodb charset=utf-8

       =>charset是创建表的字符集,常见的字符集有gbk, utf8;

       =>engine是创建表是使用的引擎,不同的引擎有不同的特性,归纳如下:

引擎名称 事务 速度 容灾恢复
InnoDB  支持 慢(不支持full-text搜索) 不支持
MyISAM 不支持 快(支持full-text搜索) 不支持
MEMORY 不支持 很快(支持full-text搜索) 不支持
ARIA 支持 支持

       =>创建表的例子:

           create table if not exists test (

            id int auto_increment,

            name char(20) not null default ' ',

            age tinyint unsigned not null default 0,

            index id(id)

          )engine=innodb, charset=utf8;

    待更新......

原文地址:https://www.cnblogs.com/xiuqingyao/p/6939646.html