Get the App
SLTechnology News&Howtos  ›  Database  › 

Suggestions for writing MySQL DML sentences

Shulou Source: shulou.com Published: 2022-06-01 07:48:31 10月05日 Update

The DML statement does not allow the use of @ number to replace the unreasonable field name: UPDATE table_name SET @ 1=NOW () WHERE @ 2room1

The correct way to write it: UPDATE table_name SET column_name1=NOW () WHERE column_name2=1

UPDATE OR DELETE forbids the unreasonable writing of the LIMIT clause: UPDATE table_name SET column_name1=NOW () WHERE column_name2=1 LIMIT 1

The correct way to write it: UPDATE table_name SET column_name1=NOW () WHERE column_name2=1

The INSERT statement needs to write the unreasonable relationship between the value and the field:

INSERT INTO table_name VALUES (NOW (), DATE_ADD (NOW (), INTERVAL + 1 DAY))

The correct way to write:

INSERT INTO table_name (aisino_create,aisino_modify) VALUES (NOW (), DATE_ADD (NOW (), INTERVAL + 1 DAY))

DML statement uses less uncertain functions: UUID (), RAND (), SYSDATE () and other functions. If there is no special use, please replace them with deterministic functions.

Tags: Writing functions statements unreasonable uncertain fields clear special names clauses common ways usefulness certainty suggestions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB Shulou Information Linux Shulou Technology