In the previous section, creating a data table, this article describes the data insertion after the CREATE table:
First, insert INTO ... values ... Insert
INSERT INTO TableName (COLUMN1,COLUMN2,COLUMN3) VALUES (' character type 1 ', ' character 2 ', ' character 3 ');
1. You can omit the column name, but the value after values should correspond to column one by one in the table.
INSERT INTO tablename values (' character 1 ', ' character type 2 ', ' character 3 ');
2, you can add a few column names, and then corresponding to increase the value of these items,
INSERT INTO TableName (COLUMN1,COLUMN3) VALUES (' character type 1 ',, ' character 3 ');
3, can add a few rows of values, separated by commas
INSERT INTO TableName (COLUMN1,COLUMN2,COLUMN3) VALUES (' character type 1 ', ' character 2 ', ' character 3 '),
(' character type 21 ', ' character Type 22 ', ' character 23 ');
4, or use multiple INSERT statements
INSERT INTO TableName (COLUMN1,COLUMN2,COLUMN3) VALUES (' character type 1 ', ' character 2 ', ' character 3 ');
INSERT INTO TableName (COLUMN1,COLUMN2,COLUMN3) VALUES (' character type 21 ', ' character 22 ', ' character 23 ');
Second, by insert INTO ... set ... Syntax insertion
INSERT INTO TableName set column1= ";
Third, ensure the uniqueness of the column values
ALTER TABLE tablename add unique (column);
By adding a unique to the column, ensure that the column values are incremented if repeated, an error is raised.
Iv. Updating column values
Update tablename set column1= "where ... A filter statement that specifies that the column values of a row are modified, not all column values.
V. Delete a row of values
Delete from tablename where colunm1= ...;
Vi. Deleting table contents
Delete from TableName; All column values in the table are removed, and automatically growing columns are not reset.
or TRUNCATE TABLE tablename; Clear table, Reset Auto Add column (auto_increment)
MySQL data insertion, update, and deletion