4.2.12. MySQL insert data

发布时间 : 2025-10-25 13:32:49 UTC      

Page Views: 9 views

Used in the MySQL table INSERT INTO SQL statement to insert data.

You can insert data into the datasheet through the mysql > command prompt window, or through the PHP script.

Grammar

The following is a common method for inserting data into an MySQL data table INSERT INTO SQL syntax:

INSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN ); 

If the data is character type, you must use single or double quotation marks, such as “value”.

Insert data through the command prompt window

Next we will use SQL INSERT INTO Statement to the MySQL data table runoob_tbl Insert data

Example

In the following example, we will insert three pieces of data into the runoob_tbl table:

root@host# mysql -u root -p password; Enter password:******* mysql> use RUNOOB; Database changed mysql> INSERT INTO runoob_tbl -> (runoob_title, runoob_author, submission_date) -> VALUES -> ("学习 PHP", "菜鸟教程", NOW()); Query OK, 1 rows affected, 1 warnings (0.01 sec) mysql> INSERT INTO runoob_tbl -> (runoob_title, runoob_author, submission_date) -> VALUES -> ("学习 MySQL", "菜鸟教程", NOW()); Query OK, 1 rows affected, 1 warnings (0.01 sec) mysql> INSERT INTO runoob_tbl -> (runoob_title, runoob_author, submission_date) -> VALUES -> ("JAVA 教程", "RUNOOB.COM", '2016-05-06'); Query OK, 1 rows affected (0.00 sec) mysql> 

注意: Using the arrow mark-> is not part of the SQL statement, it just represents a new line. If a SQL statement is too long, we can use the enter key to create a new line to write the SQL statement. The command Terminator of the SQL statement is a semicolon.

In the above example, we did not provide the data for runoob_id because we set it to the AUTO_INCREMENT property when we created the table. Therefore, this field is automatically incremented without us to set it. In the instance, NOW () is a MySQL function that returns a date and time.

Next, we can view the data table data with the following statement:

Read the data table:

select\*fromrunoob_tbl; 

Output result:

Image0

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。