My_Project

资料整理


SQL语句-索引

<p>1、普通索引: index</p> <pre><code>(1)说明:是最基本的索引,没有任何限制,字段可以重复,可以为空。 (2)直接创建索引 Create index 索引名称 on 表名(字段(length)); Create index lukeru on student(name); (3)修改表结构的方式添加索引 Alter table 表名 add index 索引名称on (column(length)); (4)删除索引 Drop index 索引名称 on table ;</code></pre> <p>2、唯一索引:unique</p> <pre><code>(1)说明:可以允许为空,不允许值重复,要求所有记录都唯一。 (2)创建唯一索引 Create unqiue index索引名称 on table(column(length)); unqiue index:唯一索引关键字</code></pre> <p>3、主键索引:primary key</p> <pre><code>(1)说明:也就是在唯一索引的基础上相应的列必须为主键。</code></pre> <p>4、全文索引:fulltext</p> <pre><code>(1)说明:用来对大表的文本域(char,varchar,text)进行索引。语法和普通索引一样。 (1)修改表结构添加全文索引 Alter table article add full text index_content(content) (1)直接创建索引 Cleate full text index_content on article(content)</code></pre> <p>5、组合索引</p> <pre><code>(1)说明:指多个字段上创建的索引,只有在查询条件中使用了创建索引时的第一个字段,索引才会被使用。使用组合索引时遵循最左前缀集合。 alter table‘table’add index name_city_age (name,city,age);</code></pre> <p>6、查找已创建的索引</p> <pre><code>(1)打开navicat for Mysql-&gt;选择一个表-&gt;右键选择‘设计表’-&gt;选择‘索引’。</code></pre> <p>7、展示索引</p> <pre><code>(1)show index from table; 或show keys from table;</code></pre> <p>8、查找索引</p> <pre><code>Select查询语句 索引增删改查: https://jingyan.baidu.com/article/5225f26b44361ee6fa09083a.html?qq-pf-to=pcqq.c2c</code></pre>

页面列表

ITEM_HTML