LOCK (original) (raw)

LOCK statement obtains a table-level lock, waiting if necessary for any conflicting locks to be released.
More about LOCK statement can be found:
PostgreSQL - https://www.postgresql.org/docs/11/sql-lock.html
MySQL - https://dev.mysql.com/doc/refman/8.0/en/lock-tables.html
MariaDB - https://mariadb.com/kb/en/library/lock-tables/

Following clauses are supported:

Example

lockStmt := Address. LOCK(). IN(LOCK_ACCESS_SHARE). NOWAIT()

Debug SQL of above statement:

LOCK TABLE dvds.address IN ACCESS SHARE MODE NOWAIT;

Execute statement

To execute update statement and get sql.Result:

res, err := lockStmt.Exec(db)

Use ExecContext to provide context object to execution.