Home Backend Development PHP Tutorial A Mysql table creation statement

A Mysql table creation statement

Aug 08, 2016 am 09:33 AM
comment NOT null varchar

<span> 1</span> <span>DROP</span> <span>TABLE</span> <span>IF</span> <span>EXISTS</span><span> `nuvue`;
</span><span> 2</span> 
<span> 3</span> <span>CREATE</span> <span>TABLE</span><span> `nuvue`(
</span><span> 4</span>     `id` <span>INT</span>(<span>10</span>) UNSIGNED <span>NOT</span> <span>NULL</span><span> AUTO_INCREMENT,
</span><span> 5</span>     `status` <span>TINYINT</span>(<span>2</span>) UNSIGNED <span>NOT</span> <span>NULL</span> <span>DEFAULT</span> <span>0</span> COMMENT <span>'</span><span>状态</span><span>'</span><span>,
</span><span> 6</span>     `uid` <span>INT</span>(<span>10</span>) UNSIGNED <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>创建用户</span><span>'</span><span>,
</span><span> 7</span>     `province_id` <span>TINYINT</span>(<span>3</span>)  UNSIGNED <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>一级城市</span><span>'</span><span>,
</span><span> 8</span>     `city_id` <span>TINYINT</span>(<span>3</span>)  UNSIGNED <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>二级地区</span><span>'</span><span>,
</span><span> 9</span>     `name` <span>VARCHAR</span>(<span>100</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>场地名称</span><span>'</span><span>,
</span><span>10</span>     `logo_url` <span>VARCHAR</span>(<span>100</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>场地Logo</span><span>'</span><span>,
</span><span>11</span>     `location_address` <span>VARCHAR</span>(<span>200</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>场地地址</span><span>'</span><span>,
</span><span>12</span>     `location_point` <span>VARCHAR</span>(<span>30</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>场地坐标</span><span>'</span><span>,
</span><span>13</span>     `caoncat_phone` <span>VARCHAR</span>(<span>20</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>联系人电话</span><span>'</span><span>,
</span><span>14</span>     `type` ENUM(<span>'</span><span>livehouse</span><span>'</span>,<span>'</span><span>theare</span><span>'</span>,<span>'</span><span>bar</span><span>'</span>,<span>'</span><span>bookshop</span><span>'</span>,<span>'</span><span>other</span><span>'</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>场地类型</span><span>'</span><span>,
</span><span>15</span>     `phone` <span>VARCHAR</span>(<span>20</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>场地电话</span><span>'</span><span>,
</span><span>16</span>     `area` <span>VARCHAR</span>(<span>10</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>场地面积</span><span>'</span><span>,
</span><span>17</span>     `people` <span>VARCHAR</span>(<span>10</span>) <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>容纳人数</span><span>'</span><span>,
</span><span>18</span>     `device` <span>VARCHAR</span>(<span>100</span>) <span>NOT</span> <span>NULL</span> <span>DEFAULT</span> <span>''</span> COMMENT <span>'</span><span>场地设备</span><span>'</span><span>,
</span><span>19</span>     `introduction` <span>VARCHAR</span>(<span>100</span>) <span>NOT</span> <span>NULL</span> <span>DEFAULT</span> <span>''</span> COMMENT <span>'</span><span>场地简介</span><span>'</span><span>,
</span><span>20</span>     `create_at` <span>DATETIME</span> <span>NOT</span> <span>NULL</span> COMMENT <span>'</span><span>创建时间</span><span>'</span><span>,
</span><span>21</span>     <span>PRIMARY</span> <span>KEY</span><span> `id`(`id`),
</span><span>22</span>     <span>UNIQUE</span> <span>KEY</span><span> `name`(`name`),
</span><span>23</span>     <span>KEY</span><span> `idx_type`(`type`),
</span><span>24</span>     <span>KEY</span><span> `idx_uid`(`uid`),
</span><span>25</span>     <span>KEY</span><span> `idx_status`(`status`),
</span><span>26</span>     <span>KEY</span><span> `idx_location`(`province_id`,`city_id`)
</span><span>27</span> )ENGINE<span>=</span> Myisam <span>DEFAULT</span> CHARSET <span>=</span> utf8;
Copy after login

The above introduces a Mysql table creation statement, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between null and NULL in c language What is the difference between null and NULL in c language Sep 22, 2023 am 11:48 AM

The difference between null and NULL in C language is: null is a macro definition in C language, usually used to represent a null pointer, which can be used to initialize pointer variables, or to determine whether the pointer is null in a conditional statement; NULL is a macro definition in C language A predefined constant in , usually used to represent a null value, used to represent a null pointer, null pointer array or null structure pointer.

What is the concept of mysql comment What is the concept of mysql comment Jun 02, 2023 pm 05:34 PM

Comment means remarks and annotations. In the MySQL database, comments on fields or columns are added using the comment attribute; in scripts that create new tables, comments can be added by adding the comment attribute in the field definition script. If you want to view the comments of all fields of an existing table, you can use the "showfullcolumnsfrom table name" command. In mysql, COMMENT means remarks and comments. MySQL adds comments (comment) In the MySQL database, comments on fields or columns are added using the comment attribute. In the script that creates a new table, you can add comments by adding the comment attribute in the field definition script. The sample code is as follows: c

What do undefined and null mean? What do undefined and null mean? Nov 20, 2023 pm 02:39 PM

In JavaScript, both undefined and null represent the concept of "nothing": 1. undefined represents an uninitialized variable or a non-existent property. When a variable is declared but no value is assigned to it, the value of the variable is undefined , when accessing properties that do not exist in the object, the returned value is also undefined; 2. null represents an empty object reference. In some cases, the object reference can be set to null to release the memory it occupies.

When to use null and undefined When to use null and undefined Nov 13, 2023 pm 02:11 PM

Both null and undefined indicate a lack of value or an undefined state. Depending on the usage scenario, there are some guiding principles for choosing to use null or undefined: 1. When you need to clearly indicate that a variable is empty or invalid, you can use null; 2. When a variable has been declared but not yet assigned a value, it will be set to undefined by default; 3. When you need to check whether a variable is empty or undefined, use the strict equality operator "===" to determine whether the variable is null or undefined. .

What is the difference between null and undefined What is the difference between null and undefined Nov 08, 2023 pm 04:43 PM

The difference between null and undefined is: 1. Semantic meaning; 2. Usage scenarios; 3. Comparison with other values; 4. Relationship with global variables; 5. Relationship with function parameters; 6. Nullability check; 7. Performance considerations; 8. Performance in JSON serialization; 9. Relationship with types. Detailed introduction: 1. Semantic meaning, null usually means knowing that this variable will not have any valid object value, while undefined usually means that the variable has not been assigned a value, or the object does not have this attribute; 2. Usage scenarios, etc.

What are the uses of null in java What are the uses of null in java Mar 01, 2024 am 10:10 AM

Usage: 1. Initialize the reference type variable to null, indicating that the variable does not currently point to any object; 2. Set the reference type variable to null, which can release the memory space of the object referenced by the variable and help the garbage collector to recover This object; 3. Use null to check whether a reference is empty. You can avoid the occurrence of NullPointerException by judging whether the reference is null. 4. Use null in conditional judgment to judge whether a reference is empty.

How to implement date comparison, sorting and other operations with the varchar type in mysql How to implement date comparison, sorting and other operations with the varchar type in mysql May 31, 2023 pm 01:49 PM

During the use of MySQL, dates are generally stored in datetime, timestamp and other formats. However, sometimes due to special needs or historical reasons, the date is stored in varchar format. So how should we process the date data in varchar format? ? Use function: STR_TO_DATE(str,format) The STR_TO_DATE(str,format) function is the inverse function of the DATE_FORMAT() function. It takes a string str and a format string format. STR_TO_DATE() returns a DATETIME value if the format string contains date and time components, or if the word

What is the difference between char and varchar in mysql What is the difference between char and varchar in mysql Sep 04, 2023 pm 02:16 PM

The differences between char and varchar in mysql are: 1. CHAR is fixed length, while VARCHAR is variable length; 2. CHAR storage and retrieval efficiency is high, while VARCHAR storage and retrieval efficiency is not high; 3. CHAR takes up storage space, VARCHAR can save storage space.

See all articles