SQL_DML_Add, delete and modify data in the table

DML: add, delete and modify data in the table

1. Add data:

  • Syntax:
    * 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 must correspond one to one.
    2. If the column name is not defined after the table name,
    insert into the table name values ​​(value 1, value 2, ... value n) is added to all columns by default ;
    3. In addition to numeric types, other types need to use quotation marks (single and double Can be caused

Insert picture description here
Insert picture description here
Insert picture description here

2. Delete data:

  • Syntax:
    * delete from table name [where condition]

  • Note:
    1. If no conditions are added, all records in the table will be deleted.
    2. If you want to delete all records

      * 1. delete from 表名; -- 不推荐使用。有多少条记录就会执行
      多少次删除操作
      * 2. TRUNCATE TABLE 表名; -- 推荐使用,效率更高 先删除表,
       然后再创建一张一样的表。
    

Insert picture description here
Insert picture description here

3. Modify the data:

  • Syntax:
    * 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.
    Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44664432/article/details/109264315