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

How to create data Table in MySql

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

It is believed that many inexperienced people have no idea about how to create a data table in MySql. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

After the database is created successfully, you need to create a data table. by creating a data table, you mean creating a new table in an existing database. It is important to note that before manipulating the data table, you should use the "USE database name" to specify which database the operation is in, otherwise a "No database selected" error will be thrown. The basic syntax format for creating a data table is as follows:

CREATE TABLE table name

(

Field name 1, data type [integrity constraint]

Field name 2, data type [integrity constraint]

...

Field name n, data type [integrity constraint]

)

In the above syntax format, "table name" refers to the name of the data table created, "field name" refers to the column name of the data table, and "integrity constraint" refers to some special constraints of the field. For example, create a table TB _ grade that stores student scores.

Field name data type remarks

Number of idINT (11) student

Name of nameVARCHR (20) student

The grades of gredeFLOAT students

To create the data table as above, we need to first create a grade_db database with the following SQL statement:

Create database grade_db

Through the SHOW DATABASES; command, we can see that "grade_db" has often been successful.

Select the database you created, and the SQL statement is as follows:

Use grade_db

The SQL statement to create the data table is as follows:

Create table tb_grade

(

Id int (11)

Name varchar (20)

Grade flaot

)

After reading the above, have you mastered the method of how to create data tables in MySql? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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