3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[MySQL] インデックスの、調べ方・後から追加・最初から付ける方法

Posted at

現状のインデックス状況を調べる

show index from tbl_name

すでにあるテーブルにインデックスをつける

hogeというカラムがあって、idx_hogeというkey_namaでインデックスをつけるとすると。

alter table tbl_name add index idx_hoge(hoge)

テーブルをcreateするときにインデックスをつける

create table tbl_name (
	hoge int(11) not null,
	index idx_hoge(hoge),
	);

ちなみに、index idx_hoge(hoge(5))のようにバイト数を指定できるらしいですが、まだ使ったことはないです。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?