LLMpediaThe first transparent, open encyclopedia generated by LLMs

UPDATE (SQL statement)

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Parent: SQL Hop 4
Expansion Funnel Raw 36 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted36
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
UPDATE (SQL statement)
NameUPDATE
TypeSQL statement
IntroducedRelational model era
PurposeModify existing rows in a table
StandardSQL

UPDATE (SQL statement) is a data-manipulation statement in the Structured Query Language family used to modify existing rows in a relational database table. It appears in implementations by vendors such as Oracle Corporation, Microsoft Corporation, IBM, MySQL, and PostgreSQL and is standardized by organizations like ISO and ANSI. UPDATE is central to transactional systems in contexts ranging from Walmart-scale retail platforms to scientific archives managed by institutions such as the National Aeronautics and Space Administration.

Syntax

The canonical form in many implementations follows: UPDATE

SET = [, ...] [WHERE ] [FROM ] [ORDER BY ] [LIMIT ];. Vendors add extensions: Oracle Corporation supports subquery expressions and the MERGE statement pattern; Microsoft Corporation's SQL Server provides OUTPUT clauses and joins in UPDATE with FROM; PostgreSQL allows FROM and RETURNING; MySQL offers multi-table UPDATE and LIMIT. UPDATE interacts with other SQL clauses standardized by ISO and ANSI including SELECT, JOIN, and WHERE predicates that can reference UNION, EXISTS, and correlated subqueries from work influenced by researchers at IBM and Bell Labs.

Examples

Simple updates: UPDATE users SET status='active' WHERE last_login > '2025-01-01'; illustrates a single-table mutation similar to examples in SQL Server and PostgreSQL documentation. Joins in UPDATE: UPDATE orders SET total = o.subtotal + o.tax FROM orders o JOIN customers c ON o.customer_id = c.id WHERE c.region = 'EMEA'; mirrors patterns described by Microsoft Corporation and practitioners at Oracle Corporation. Subquery use: UPDATE products SET price = price * 0.9 WHERE id IN (SELECT product_id FROM promotions WHERE campaign = 'Holiday'); echoes examples from MySQL and PostgreSQL tutorials. RETURNING/OUTPUT: UPDATE inventory SET quantity = quantity - 1 WHERE sku='ABC' RETURNING id, quantity; demonstrates a PostgreSQL-style RETURNING clause and is analogous to SQL Server OUTPUT semantics.

Semantics and Behavior

UPDATE semantics are defined by the relational model contributions of E. F. Codd and formalized in standards by ISO. An UPDATE typically performs value assignment per targeted row, evaluating SET expressions either once per statement or per row depending on the engine; this distinction appears in comparisons between MySQL's evaluation rules and PostgreSQL's row-at-a-time semantics. WHERE predicates determine row selection and can employ correlated subqueries that reference the target table; such correlations were topics at Bell Labs and studied by researchers at IBM. NULL handling, type coercion, and implicit casting follow vendor-specific rules influenced by standards work at ANSI. When multiple rows match but a unique constraint exists, an UPDATE may raise constraint violations handled by Oracle Corporation's error reporting or Microsoft Corporation's transaction rollback behavior.

Performance and Concurrency

UPDATE performance depends on indexing strategies advocated by practitioners at Facebook and Google for large-scale systems, and on storage engine behavior studied at Sun Microsystems and IBM. Index maintenance, write amplification, and row-locking are critical: MySQL with InnoDB uses row-level locks and MVCC akin to PostgreSQL, while some NoSQL adopters avoid UPDATE semantics entirely. Concurrency control models—optimistic concurrency influenced by Berkeley DB research and pessimistic locking used in Oracle Corporation deployments—affect throughput and latency. Bulk updates can be optimized with partition-wise operations used by Amazon Web Services data teams and by batching strategies reminiscent of Google's MapReduce planning for large datasets.

Security and Permissions

Privilege models for UPDATE are governed by access-control systems found in Microsoft Corporation's Windows-based SQL Server, Oracle Corporation's role-based access control, and PostgreSQL's GRANT/REVOKE mechanisms standardized by ANSI. Granting UPDATE privileges on a table can be restricted by column with GRANT UPDATE (column) in PostgreSQL and Oracle Corporation; auditing tools from Splunk and IBM often track UPDATE statements for compliance regimes such as those mandated by Sarbanes–Oxley Act and HIPAA. Injection risks arise when UPDATE statements are constructed from untrusted input—issues highlighted in reports by OWASP and security teams at Microsoft Corporation; parameterization, prepared statements, and stored procedures advocated by Oracle Corporation and PostgreSQL communities mitigate these risks.

Dialect Differences

SQL dialects diverge in UPDATE features. PostgreSQL offers RETURNING and FROM, while MySQL adds multi-table UPDATE and extensions to LIMIT; SQL Server supports MERGE-like patterns and OUTPUT with table variables; Oracle Corporation favors MERGE and correlated subqueries without a native LIMIT. Syntax for joins, locking hints (e.g., FOR UPDATE), and evaluation order differ across IBM Db2, SQLite (used in projects by Mozilla and Android), and cloud offerings such as Amazon Aurora and Google Cloud SQL. Standards work by ISO and ANSI reduces but does not eliminate these dialectal gaps, so portability guides from organizations like PostgreSQL Global Development Group and vendors such as Oracle Corporation remain important for cross-platform development.

Category:Structured Query Language