uTools-Manuals/docs/sql/CREATE INDEX 语句.html
2019-04-21 11:50:48 +08:00

5 lines
1.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="m-bg">
<h1>SQL CREATE INDEX 语句</h1>
<p class="intro">CREATE INDEX 语句用于在表中创建索引。</p> <p class="intro">在不读取整个表的情况下,索引使数据库应用程序可以更快地查找数据。</p> <h2>索引</h2> <p>您可以在表中创建索引,以便更加快速高效地查询数据。</p> <p>用户无法看到索引,它们只能被用来加速搜索/查询。</p> <p><b>注释:</b>更新一个包含索引的表需要比更新一个没有索引的表花费更多的时间,这是由于索引本身也需要更新。因此,理想的做法是仅仅在常常被搜索的列(以及表)上面创建索引。</p> <h3>SQL CREATE INDEX 语法</h3> <p>在表上创建一个简单的索引。允许使用重复的值:</p> <div class="code notranslate"><pre><div> CREATE INDEX index_name<br/> ON table_name (column_name)</div></pre></div> <h3>SQL CREATE UNIQUE INDEX 语法</h3> <p>在表上创建一个唯一的索引。不允许使用重复的值唯一的索引意味着两个行不能拥有相同的索引值。Creates a unique index on a table. Duplicate values are not allowed:</p> <div class="code notranslate"><pre><div> CREATE UNIQUE INDEX index_name<br/> ON table_name (column_name)</div></pre></div> <p><b>注释:</b>用于创建索引的语法在不同的数据库中不一样。因此,检查您的数据库中创建索引的语法。 </p> <h2>CREATE INDEX 实例</h2> <p>下面的 SQL 语句在 "Persons" 表的 "LastName" 列上创建一个名为 "PIndex" 的索引:</p> <div class="code notranslate"><pre><div> CREATE INDEX PIndex<br/> ON Persons (LastName)</div></pre></div> <p>如果您希望索引不止一个列,您可以在括号中列出这些列的名称,用逗号隔开:</p> <div class="code notranslate"><pre><div> CREATE INDEX PIndex<br/> ON Persons (LastName, FirstName)</div></pre></div> <br/><div class="text-center padding-10 margin-t-5">
</div>
</div>