In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces mysql how to create a data table, the article is very detailed, has a certain reference value, interested friends must read it!
Establish the SQL general syntax for the data table:
CREATE TABLE table_name (column_name column_type)
We can create mysql data tables in two ways.
1. Create a table from the command prompt
Through the mysql > command window, you can easily create an MySQL data table using the SQL statement CREATE TABLE.
Example:
Root@host# mysql-u root-pEnter password:*mysql > use RUNOOB;Database changedmysql > CREATE TABLE runoob_tbl (- > runoob_id INT NOT NULL AUTO_INCREMENT,-> runoob_title VARCHAR (100th) NOT NULL,-> runoob_author VARCHAR (40) NOT NULL,-> submission_date DATE,-> PRIMARY KEY (runoob_id)->) ENGINE=InnoDB DEFAULT CHARSET=utf8;Query OK, 0 rows affected (0.16 sec) mysql >
Instance resolution:
● 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.
Note: the MySQL command Terminator is a semicolon;. -> is a newline identifier. Do not copy it.
2. Use PHP script to create data table
We can use the mysqli_query () function of PHP to create a data table of an existing database.
This function takes two arguments and returns TRUE on successful execution, or FALSE otherwise.
The basic syntax of the mysqli_query () function:
Mysqli_query (connection,query,resultmode)
Code example:
3. View the data sheet
After the data table is established, you can view the structure of the table from the command prompt:
This is all about how mysql created the datasheet. Thank you for reading! Hope to share the content to help you, more related 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.