Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of creating New Table in MySQL Database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail the method of creating a new table in the MySQL database. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

CREATE TABLE syntax:

CREATE TABLE [IF NOT EXISTS] table_name (column_list) engine=table_type

[IF NOT EXISTS] is mainly used to determine whether the newly created table exists.

Engine needs to specify a storage engine. You can use any storage engine, such as InnoDB,MyISAM,HEAP,EXAMPLE,CSV,ARCHIVE,MERGE, FEDERATED or NDBCLUSTER. If the storage engine is not explicitly declared, MySQL will use InnoDB by default.

Column_list is more complex to specify a list of tables. The columns of fields are separated by commas (,).

The syntax of column_list is as follows:

Column_name data_ type [size] [NOT NULL | NULL] [DEFAULT value] [AUTO_INCREMENT]

Column_name specifies the name of the column. Each column has a specific data type and size, for example: varchar (50).

NOT NULL or NULL indicates whether the column accepts a null value.

The DEFAULT value is used to specify the default value for the column.

AUTO_INCREMENT indicates that the value of the column automatically increases each time a new row is inserted into the table. Each table has one and only one AUTO_INCREMENT column.

Example:

CREATE TABLE tasks (id INT NOT NULL, subject VARCHAR (45) NULL, start_date DATE NULL, end_date DATE NULL / / Note that there cannot be "," will report an error) charset utf8 This is the end of this article on "how to create a new table in the MySQL database". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report