zoukankan      html  css  js  c++  java
  • mysql基础(2)--索引

    1.创建普通索引

    mysql> create table book(  bookid int not null,
        -> bookname varchar(255) not null,
        -> year_publication year not null,
        -> index(year_publication)
        -> );
    Query OK, 0 rows affected (0.10 sec)

    查看索引

    mysql> explain select * from book where year_publication=1990G
    *************************** 1. row ***************************
               id: 1
      select_type: SIMPLE
            table: book
       partitions: NULL
             type: ref
    possible_keys: year_publication
              key: year_publication
          key_len: 1
              ref: const
             rows: 1
         filtered: 100.00
            Extra: Using index condition
    1 row in set, 1 warning (0.00 sec)

    2.创建唯一索引

    mysql> create table t1(
        -> id int not null,
        -> name char(30) not null,
        -> unique index (id)
        -> );
    Query OK, 0 rows affected (0.02 sec)

    3.创建单列索引

    mysql> create table t2(
        -> id int not null,
        -> name char(30) not null,
        -> index SingleIdx(name(20))
        -> );
    Query OK, 0 rows affected (0.01 sec)

    4.创建组合索引

    index multiIdx(id,name);

    5.创建全文索引

    fulltext index fullTexIdx(info);

    6.添加索引

    mysql> create index bknameidx on book(bookname); 
    Query OK, 0 rows affected (0.02 sec)
    Records: 0  Duplicates: 0  Warnings: 0
  • 相关阅读:
    shell 格式化输出
    Linux tar 修改终端命令
    uniqu 用法
    HashMap按照value值进行排序
    汇编语言系列教程之基础入门 (一)
    Linux权限管理
    linux用户管理
    vim的tab键设定
    HTTP请求(GET与POST区别)和响应
    JS eval()
  • 原文地址:https://www.cnblogs.com/yankang/p/6405170.html
Copyright © 2011-2022 走看看