4.2.10. MySQL creates a data table

发布时间 :2025-10-25 12:31:22 UTC      

The following information is required to create an MySQL data table:

  • Table name

  • Table field name

  • Define each table field

Grammar

The following is the general SQL syntax for creating MySQL data tables:

CREATE TABLE table_name (column_name column_type);

In the following example, we will create the data table runoob_tbl in the RUNOOB database:

CREATE TABLE IF NOT EXISTS `runoob_tbl`(
   `runoob_id` INT UNSIGNED 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;

Instance resolution:

  • If you don’t want the field to be NULL You can set the property of the field to NOT NULL When manipulating the database, if the data entered in this field is NULL , you will report an error.

  • AUTO_INCREMENT定义列为自增的属性,一般用于主键,数值会自动加1。

  • The PRIMARY KEY keyword is used to define the column primary key. You can use multiple columns to define the primary key, separated by commas.

  • ENGINE sets the storage engine and CHARSET sets the encoding.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.