uTools-Manuals/docs/sql/CREATE TABLE 语句.html
2019-05-07 10:15:08 +08:00

11 lines
2.1 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 TABLE 语句</h1>
<h2>SQL CREATE TABLE 语句</h2> <p>CREATE TABLE 语句用于创建数据库中的表。</p> <p>表由行和列组成,每个表都必须有个表名。</p> <h3>SQL CREATE TABLE 语法</h3> <div class="code notranslate"><pre><code class="language-sql"><div> CREATE TABLE <em>table_name</em><br/> (<br/><em>column_name1 data_type</em>(<em>size</em>),<br/><em>column_name2 data_type</em>(<em>size</em>),<br/><em>column_name3 data_type</em>(<em>size</em>),<br/> ....<br/> );</div></code></pre></div> <p>column_name 参数规定表中列的名称。</p> <p>data_type 参数规定列的数据类型(例如 varchar、integer、decimal、date 等等)。</p> <p>size 参数规定表中列的最大长度。</p> <p><strong>提示:</strong>如需了解 MS Access、MySQL 和 SQL Server 中可用的数据类型,请访问我们完整的 数据类型参考手册。</p> <h2>SQL CREATE TABLE 实例</h2> <p>现在我们想要创建一个名为 "Persons" 的表包含五列PersonID、LastName、FirstName、Address 和 City。</p> <p>我们使用下面的 CREATE TABLE 语句:</p> <div class="example margin-b-10"> <h2 class="example">实例</h2> <pre><code class="language-sql"><div class="example_code notranslate"> CREATE TABLE Persons<br/> (<br/> PersonID int,<br/> LastName varchar(255),<br/> FirstName varchar(255),<br/> Address varchar(255),<br/> City varchar(255)<br/> ); </div></code></pre> </div> <p>PersonID 列的数据类型是 int包含整数。</p> <p>LastName、FirstName、Address 和 City 列的数据类型是 varchar包含字符且这些字段的最大长度为 255 个字符。</p> <p>空的 "Persons" 表如下所示:</p> <table class="reference notranslate">
<tr>
<th align="left">PersonID</th> <th align="left">LastName</th> <th align="left">FirstName</th> <th align="left">Address</th> <th align="left">City</th> </tr>
<tr>
<td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr>
</table>
<p><strong>提示:</strong>可使用 INSERT INTO 语句向空表写入数据。</p> <div class="text-center padding-10 margin-t-5">
</div>
</div>