Updated on 2025-06-30 GMT+08:00

Other Statements

Table 1 Compatibility of other syntaxes

Description

Syntax

Difference

Lock mechanism

Lock mechanism

  • The GaussDB lock mechanism can be used only in transaction blocks. There is no such restriction in MySQL.
  • After the read lock is obtained, write operations cannot be performed on the current session in MySQL, but write operations can be performed on the current session in GaussDB.
  • After MySQL locks a table, an error is reported when other tables are read. GaussDB does not have such restriction.
  • In MySQL, if the lock of the same table is obtained in the same session, the previous lock is automatically released and the transaction is committed. GaussDB does not have this mechanism.
  • In GaussDB, LOCK TABLE can be used only inside a transaction block, and UNLOCK TABLE will not be used. Locks are always released at the end of transactions.

PBE

PBE

  • In GaussDB, if a PREPARE statement with the same name is repeatedly created, an error is reported, indicating that the statement already exists. You need to delete the existing statement first. In MySQL, the old statement will be overwritten.
  • GaussDB and MySQL report errors in different phases, such as parsing and execution, during SQL statement execution. PREPARE statements process prepared statements till the parsing phrase. Therefore, in abnormal scenarios in PBE, GaussDB may be different from MySQL in terms of whether the error is reported in the PREPARE or EXECUTE phase.

Single-line comment syntax

Single-line comment syntax

The single-line comment syntax is consistent with MySQL only when the m_format_behavior_compat_options parameter includes the 'forbid_none_space_comment' option.