04. DML: Adding, deleting and modifying data in the table

04. DML: Adding, deleting and modifying data in the table

  1. adding data:
    • grammar:
      • insert into table name (column name 1, column name 2, ... column name n) values ​​(value 1, value 2, ... value n);
    • note:
      1. The column name and value should correspond one to one.
      2. 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);
      3. In addition to number types, other types need to be enclosed in quotation marks (single and double)
  2. delete data:
    • grammar:
      • delete from table name [where condition]
    • note:
      1. If no conditions are added, all records in the table are deleted.
      2. If you want to delete all records
        1. delete from table name;-not recommended. How many delete operations will be performed as many records
        2. TRUNCATE TABLE table name;-recommended, it is more efficient to delete the table first, and then create the same table.
  3. change the data:
    • grammar:

      • update table name set column name 1 = value 1, column name 2 = value 2,... [where condition];
    • note:

      1. If no conditions are added, all records in the table will be modified.

Guess you like

Origin blog.csdn.net/qq_43629083/article/details/109005331