In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to write the mysql creation table command, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The following information is required to create an MySQL data table:
● table name
● table field name
● defines each table field
Basic grammar
The following is the general SQL syntax for creating MySQL data tables:
CREATE TABLE table_name (column_name column_type)
Example: create a table from the command prompt
You can easily create an MySQL data table through the mysql > command window. You can use the SQL statement CREATE TABLE to create a data table.
1. First connect to the mysql server and enter the password
Root@host# mysql-u root-pEnter password:*
2. Enter the database RUNOOB
Use RUNOOB
3. Create a table
Mysql > CREATE TABLE runoob_tbl (- > runoob_id INT NOT NULL AUTO_INCREMENT,-> runoob_title VARCHAR (100) NOT NULL,-> runoob_author VARCHAR (40) NOT NULL,-> submission_date DATE,-> PRIMARY KEY (runoob_id)->) ENGINE=InnoDB DEFAULT CHARSET=utf8
Output:
Query OK, 0 rows affected (0.16 sec)
Indicates that the datasheet was created successfully.
Note: the MySQL command Terminator is a semicolon;.
Note:-> is a newline identifier, do not copy.
Example parsing:
● if you do not want the field to be NULL, you can set the property of the field to NOT NULL. If you enter the data of the field as NULL when operating the database, you will report an error.
The ● AUTO_INCREMENT definition is listed as a self-increasing attribute, which is generally used for primary keys, and the value is automatically incremented by 1.
The ● PRIMARY KEY keyword is used to define column primary keys. You can use multiple columns to define the primary key, separated by commas.
● ENGINE sets the storage engine and CHARSET sets the encoding.
We can use the command to view the command line to view the table structure
The above is all the contents of the mysql create table command, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.