04. DML: Adding, deleting and modifying data in the table
- adding data:
- grammar:
- insert into table name (column name 1, column name 2, ... column name n) values (value 1, value 2, ... value n);
- note:
- The column name and value should correspond one to one.
- If the column name is not defined after the table name, the default is to add values to all columns
insert into table name values (value 1, value 2, ... value n); - In addition to number types, other types need to be enclosed in quotation marks (single and double)
- grammar:
- delete data:
- grammar:
- delete from table name [where condition]
- note:
- If no conditions are added, all records in the table are deleted.
- If you want to delete all records
- delete from table name;-not recommended. How many delete operations will be performed as many records
- TRUNCATE TABLE table name;-recommended, it is more efficient to delete the table first, and then create the same table.
- grammar:
- change the data:
-
grammar:
- update table name set column name 1 = value 1, column name 2 = value 2,... [where condition];
-
note:
- If no conditions are added, all records in the table will be modified.
-