站内搜索: 请输入搜索关键词
当前页面: 图书首页 > MySQL Tutorial

MySQL Tutorial

[ Directory ] Previous Section Next Section

Using REPLACE

The REPLACE statement is exactly like the INSERT statement except that if a key clash occurs, the new row you are inserting will replace the old row.

This is the general form of REPLACE from the MySQL manual:


REPLACE [LOW_PRIORITY | DELAYED]
        [INTO] tbl_name [(col_name,...)]
        VALUES (expression,...),(...),...

or  REPLACE [LOW_PRIORITY | DELAYED]
        [INTO] tbl_name [(col_name,...)]
        SELECT ...

or  REPLACE [LOW_PRIORITY | DELAYED]
        [INTO] tbl_name
        SET col_name=expression, col_name=expression,...

The similarity to INSERT should be obvious.

    [ Directory ] Previous Section Next Section