3.DML语句

作者: Stone_説 | 来源:发表于2020-04-14 01:49 被阅读0次

    DML:INDERT,DELETE,UPDATE
    INSERT
    一次插入一行或多行数据,语法如下:

    INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name,...)] 
    {VALUES |VALUE} ({expr |DEFAULT},...),(...),... [ ON DUPLICATE KEY UPDATE 如果重复更新之 col_name=expr [, col_name=expr] ...] 
    简化写法:
    INSERT tbl_name [(col1,...)] VALUES (val1,...),(val2,...)
    
    INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name SET 
    col_name={expr |DEFAULT},... [ ON DUPLICATE KEY UPDATE col_name=expr [,col_name=expr]...]
    
    INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name SELECT
    [ ON DUPLICATE KEY UPDATE col_name=expr [,col_name=expr]...]
    

    UPDATE

    UPDATE [LOW_PRIORITY] [IGNORE] table_reference SET col_name1={expr1|DEFAULT} 
    [,col_name2={expr2|DEFAULT}]... [WHERE where_condition] [ORDER BY ...] [LIMIT row_count]
    注意:
      一定要有限制条件,否则将修改所有行的指定字段
       显示条件:
        WHERE,LIMIT
    mysql 选项:-U|--safe-updates| --i-am-a-dummy
    

    DELETE

    DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [WHERE where_condition] 
    [ORDER BY ...] [LIMIT row_count]
    可先排序在指定删除的行数
    注意:一定要有限制条件,否则将清空表中的所有数据
      限制条件:
        WHERE
        LIMIT
    TRUNCATE TABLE tbl_name;清空表
    

    相关文章

      网友评论

        本文标题:3.DML语句

        本文链接:https://www.haomeiwen.com/subject/bysamhtx.html