必須會的sql語句(四) 數(shù)據(jù)刪除和更新

字號:


    1)刪除記錄
    delete from 表名 where id ='xx'
    2)刪除所有數(shù)據(jù),并回歸初始化標(biāo)識字段。
    truncate table 表名
    3)delete與truncate區(qū)別
    a. truncate是能使種子回到初始值
    b. truncate不能加條件
    c. truncate不能涉及觸發(fā)器
    d. truncate性能要比delete高得多
    2.更新
    1)基礎(chǔ)的update
    update 表名
    set [列名]='值'
    where [列名] ='值'
    2)和replace一起使用
    --19歲以上名字中的'星'特?fù)Q成'★'。
    update 表名
    set name = replace(name,'星','★')
    where age > 19