{"action":"created","comment":{"url":"https://api.github.com/repos/cockroachdb/docs/pulls/comments/127186967","pull_request_review_id":49743683,"id":127186967,"diff_hunk":"@@ -8,16 +8,399 @@ The `UPDATE` [statement](sql-statements.html) updates rows in a table.\n \n <div id=\"toc\"></div>\n \n-## Synopsis\n+## Required Privileges \n \n-{% include sql/{{ page.version.version }}/diagrams/update.html %}\n+The user must have the `SELECT` and `UPDATE` [privileges](privileges.html) on the table.\n \n-## Required Privileges\n+## Synopsis\n \n-The user must have the `SELECT` and `UPDATE` [privileges](privileges.html) on the table.\n+<div>{% include sql/v1.0/diagrams/update.html %}</div>\n \n ## Parameters\n \n-| Parameter | Description |\n-|-----------|-------------|\n-|  |  |\n+Parameter | Description\n+----------|------------\n+`table_name` | The name of the table that contains the rows you want to update.\n+`AS name` | An alias for the table name. When an alias is provided, it completely hides the actual table name.\n+`column_name` | The name of the column whose values you want to update. To update the values of multiple columns, use a comma-separated list of column names.\n+`a_expr` | The new value you want to use, the [aggregate function](functions-and-operators.html#aggregate-functions) you want to perform, or the [value expression](sql-expressions.html) you want to use.\n+`DEFAULT` | To fill columns with their [default values](default-value.html), use `DEFAULT VALUES` in place of `a_expr`. To fill a specific column with its default value, leave the value out of the `a_expr` or use `DEFAULT` at the appropriate position. \n+`column_name_list` | A comma-separated list of column names, in parentheses.\n+`select_with_parens` | A comma-separated list of values or [value expressions](sql-expressions.html), in parentheses. To update values of multiple rows, use a comma-separated list of parentheses. <br><br>Each value must match the [data type](data-types.html) of its column. Also, if column names are listed (`qualified_name_list`), values must be in corresponding order; otherwise, they must follow the declared order of the columns in the table.\n+`WHERE a_expr`| `a_expr` must be an expression that returns Boolean values using columns (e.g. `<column> = <value>`). Update rows that return `TRUE`.<br><br>__Without a `WHERE` clause in your statement, `UPDATE` updates all rows from the table.\n+`RETURNING target_list` | Return values based on rows updated, where `target_list` can be specific column names from the table, `*` for all columns, or a computation on specific columns. <br><br>To return nothing in the response, not even the number of rows updated, use `RETURNING NOTHING`.\n+\n+## Examples\n+\n+### Update a Single Row\n+\n+~~~ sql\n+> SELECT * FROM accounts;\n+~~~\n+~~~\n++----+----------+----------+\n+| id | balance  | customer |\n++----+----------+----------+\n+|  1 | 10000.50 | michael  |\n+|  2 |   4000.0 | jim      |\n+|  3 |   8700.0 | pam      |\n+|  4 |   3400.0 | andy     |\n++----+----------+----------+\n+(4 rows)\n+~~~\n+\n+~~~ sql\n+> UPDATE accounts SET balance = 5000.0 WHERE id = 2;\n+\n+> SELECT * FROM accounts;\n+~~~\n+~~~\n++----+----------+----------+\n+| id | balance  | customer |\n++----+----------+----------+\n+|  1 | 10000.50 | michael  |\n+|  2 |   5000.0 | jim      |\n+|  3 |   8700.0 | pam      |\n+|  4 |   3400.0 | andy     |\n++----+----------+----------+\n+(4 rows)\n+~~~\n+\n+~~~ sql\n+> UPDATE accounts SET (balance, customer) = (9000.0, 'kelly') WHERE id = 2;\n+\n+> SELECT * FROM accounts;\n+~~~\n+~~~\n++----+----------+----------+\n+| id | balance  | customer |\n++----+----------+----------+\n+|  1 | 10000.50 | michael  |\n+|  2 |   9000.0 | kelly   |\n+|  3 |   8700.0 | pam      |\n+|  4 |   3400.0 | andy     |\n++----+----------+----------+\n+(4 rows)\n+~~~\n+\n+~~~ sql\n+> UPDATE accounts SET balance = 6300.0, customer = 'stanley' WHERE id = 3;\n+\n+> SELECT * FROM accounts;\n+~~~\n+\n+~~~\n++----+----------+----------+\n+| id | balance  | customer |\n++----+----------+----------+\n+|  1 | 10000.50 | michael  |\n+|  2 |   9000.0 | kelly   |\n+|  3 |   6300.0 | stanley  |\n+|  4 |   3400.0 | andy     |\n++----+----------+----------+\n+(4 rows)\n+~~~\n+\n+### Update with default values\n+\n+~~~ sql\n+> UPDATE accounts SET balance = DEFAULT where customer = 'stanley';\n+\n+> SELECT * FROM accounts;\n+~~~\n+~~~\n++----+----------+----------+\n+| id | balance  | customer |\n++----+----------+----------+\n+|  1 | 10000.50 | michael  |\n+|  2 |   9000.0 | kelly    |\n+|  3 | NULL     | stanley  |\n+|  4 |   3400.0 | andy     |\n++----+----------+----------+\n+(4 rows)\n+~~~\n+\n+### Update from a SELECT statement\n+~~~ sql\n+> UPDATE accounts SET (balance, customer) = (SELECT balance, customer FROM accounts WHERE id = 2) WHERE id = 4;\n+\n+> SELECT * FROM accounts;\n+~~~\n+\n+~~~\n++----+----------+----------+\n+| id | balance  | customer |\n++----+----------+----------+\n+|  1 | 10000.50 | michael  |\n+|  2 |   9000.0 | kelly    |\n+|  3 | NULL     | stanley  |\n+|  4 |   9000.0 | kelly    |\n++----+----------+----------+\n+(4 rows)\n+~~~\n+\n+### Update All Rows\n+\n+{{site.data.alerts.callout_danger}}If you don't use the WHERE clause to specify the rows to be updated, the values for all rows will be updated.{{site.data.alerts.end}}\n+\n+~~~ sql\n+> UPDATE accounts SET balance = 5000.0;\n+\n+> SELECT * FROM accounts;\n+~~~ \n+~~~\n++----+---------+----------+\n+| id | balance | customer |\n++----+---------+----------+\n+|  1 |  5000.0 | michael  |\n+|  2 |  5000.0 | kelly    |\n+|  3 |  5000.0 | stanley  |\n+|  4 |  5000.0 | kelly    |\n++----+---------+----------+\n+(4 rows)\n+~~~\n+\n+### Update and Return Values\n+\n+In this example, the `RETURNING` clause returns the `id` values of the rows updated, which are generated server-side by the `unique_rowid()` function. The language-specific versions assume that you have installed the relevant [client drivers](install-client-drivers.html).","path":"v1.0/update.md","position":165,"original_position":165,"commit_id":"53dc9857ed0c7cae4d7176ae3eae33acccf1cb1c","original_commit_id":"53dc9857ed0c7cae4d7176ae3eae33acccf1cb1c","user":{"login":"jseldess","id":15893490,"avatar_url":"https://avatars1.githubusercontent.com/u/15893490?v=3","gravatar_id":"","url":"https://api.github.com/users/jseldess","html_url":"https://github.com/jseldess","followers_url":"https://api.github.com/users/jseldess/followers","following_url":"https://api.github.com/users/jseldess/following{/other_user}","gists_url":"https://api.github.com/users/jseldess/gists{/gist_id}","starred_url":"https://api.github.com/users/jseldess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jseldess/subscriptions","organizations_url":"https://api.github.com/users/jseldess/orgs","repos_url":"https://api.github.com/users/jseldess/repos","events_url":"https://api.github.com/users/jseldess/events{/privacy}","received_events_url":"https://api.github.com/users/jseldess/received_events","type":"User","site_admin":false},"body":"Some of the text taken from the `insert` example is not correct here. You need to remove the clause:\r\n\r\n>which are generated server-side by the `unique_rowsid()` function. ","created_at":"2017-07-13T10:57:24Z","updated_at":"2017-07-13T10:57:24Z","html_url":"https://github.com/cockroachdb/docs/pull/1707#discussion_r127186967","pull_request_url":"https://api.github.com/repos/cockroachdb/docs/pulls/1707","_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/docs/pulls/comments/127186967"},"html":{"href":"https://github.com/cockroachdb/docs/pull/1707#discussion_r127186967"},"pull_request":{"href":"https://api.github.com/repos/cockroachdb/docs/pulls/1707"}}},"pull_request":{"url":"https://api.github.com/repos/cockroachdb/docs/pulls/1707","id":130277553,"html_url":"https://github.com/cockroachdb/docs/pull/1707","diff_url":"https://github.com/cockroachdb/docs/pull/1707.diff","patch_url":"https://github.com/cockroachdb/docs/pull/1707.patch","issue_url":"https://api.github.com/repos/cockroachdb/docs/issues/1707","number":1707,"state":"open","locked":false,"title":"[WIP]: Completed Update statement documentation","user":{"login":"Amruta-Ranade","id":11484018,"avatar_url":"https://avatars0.githubusercontent.com/u/11484018?v=3","gravatar_id":"","url":"https://api.github.com/users/Amruta-Ranade","html_url":"https://github.com/Amruta-Ranade","followers_url":"https://api.github.com/users/Amruta-Ranade/followers","following_url":"https://api.github.com/users/Amruta-Ranade/following{/other_user}","gists_url":"https://api.github.com/users/Amruta-Ranade/gists{/gist_id}","starred_url":"https://api.github.com/users/Amruta-Ranade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Amruta-Ranade/subscriptions","organizations_url":"https://api.github.com/users/Amruta-Ranade/orgs","repos_url":"https://api.github.com/users/Amruta-Ranade/repos","events_url":"https://api.github.com/users/Amruta-Ranade/events{/privacy}","received_events_url":"https://api.github.com/users/Amruta-Ranade/received_events","type":"User","site_admin":false},"body":"Closes #499 \r\nNeed to self-review the content, but fixed formatting issues.","created_at":"2017-07-13T03:04:40Z","updated_at":"2017-07-13T10:57:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a838501f07c94f1883b339a684548f1799392e2","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/cockroachdb/docs/pulls/1707/commits","review_comments_url":"https://api.github.com/repos/cockroachdb/docs/pulls/1707/comments","review_comment_url":"https://api.github.com/repos/cockroachdb/docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockroachdb/docs/issues/1707/comments","statuses_url":"https://api.github.com/repos/cockroachdb/docs/statuses/53dc9857ed0c7cae4d7176ae3eae33acccf1cb1c","head":{"label":"cockroachdb:update_stmt","ref":"update_stmt","sha":"53dc9857ed0c7cae4d7176ae3eae33acccf1cb1c","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars0.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":48004987,"name":"docs","full_name":"cockroachdb/docs","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars0.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/docs","description":"CockroachDB user documentation","fork":false,"url":"https://api.github.com/repos/cockroachdb/docs","forks_url":"https://api.github.com/repos/cockroachdb/docs/forks","keys_url":"https://api.github.com/repos/cockroachdb/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/docs/teams","hooks_url":"https://api.github.com/repos/cockroachdb/docs/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/docs/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/docs/events","assignees_url":"https://api.github.com/repos/cockroachdb/docs/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/docs/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/docs/tags","blobs_url":"https://api.github.com/repos/cockroachdb/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/docs/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/docs/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/docs/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/docs/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/docs/subscription","commits_url":"https://api.github.com/repos/cockroachdb/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/docs/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/docs/merges","archive_url":"https://api.github.com/repos/cockroachdb/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/docs/downloads","issues_url":"https://api.github.com/repos/cockroachdb/docs/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/docs/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/docs/releases{/id}","deployments_url":"https://api.github.com/repos/cockroachdb/docs/deployments","created_at":"2015-12-14T22:29:27Z","updated_at":"2017-07-10T04:52:14Z","pushed_at":"2017-07-13T10:35:51Z","git_url":"git://github.com/cockroachdb/docs.git","ssh_url":"git@github.com:cockroachdb/docs.git","clone_url":"https://github.com/cockroachdb/docs.git","svn_url":"https://github.com/cockroachdb/docs","homepage":"https://cockroachlabs.com/docs/stable","size":56977,"stargazers_count":27,"watchers_count":27,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":53,"mirror_url":null,"open_issues_count":324,"forks":53,"open_issues":324,"watchers":27,"default_branch":"master"}},"base":{"label":"cockroachdb:master","ref":"master","sha":"abd32d1c9cb33a3a7735450b7e0f52866e933f42","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars0.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":48004987,"name":"docs","full_name":"cockroachdb/docs","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars0.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/docs","description":"CockroachDB user documentation","fork":false,"url":"https://api.github.com/repos/cockroachdb/docs","forks_url":"https://api.github.com/repos/cockroachdb/docs/forks","keys_url":"https://api.github.com/repos/cockroachdb/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/docs/teams","hooks_url":"https://api.github.com/repos/cockroachdb/docs/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/docs/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/docs/events","assignees_url":"https://api.github.com/repos/cockroachdb/docs/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/docs/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/docs/tags","blobs_url":"https://api.github.com/repos/cockroachdb/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/docs/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/docs/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/docs/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/docs/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/docs/subscription","commits_url":"https://api.github.com/repos/cockroachdb/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/docs/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/docs/merges","archive_url":"https://api.github.com/repos/cockroachdb/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/docs/downloads","issues_url":"https://api.github.com/repos/cockroachdb/docs/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/docs/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/docs/releases{/id}","deployments_url":"https://api.github.com/repos/cockroachdb/docs/deployments","created_at":"2015-12-14T22:29:27Z","updated_at":"2017-07-10T04:52:14Z","pushed_at":"2017-07-13T10:35:51Z","git_url":"git://github.com/cockroachdb/docs.git","ssh_url":"git@github.com:cockroachdb/docs.git","clone_url":"https://github.com/cockroachdb/docs.git","svn_url":"https://github.com/cockroachdb/docs","homepage":"https://cockroachlabs.com/docs/stable","size":56977,"stargazers_count":27,"watchers_count":27,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":53,"mirror_url":null,"open_issues_count":324,"forks":53,"open_issues":324,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/docs/pulls/1707"},"html":{"href":"https://github.com/cockroachdb/docs/pull/1707"},"issue":{"href":"https://api.github.com/repos/cockroachdb/docs/issues/1707"},"comments":{"href":"https://api.github.com/repos/cockroachdb/docs/issues/1707/comments"},"review_comments":{"href":"https://api.github.com/repos/cockroachdb/docs/pulls/1707/comments"},"review_comment":{"href":"https://api.github.com/repos/cockroachdb/docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockroachdb/docs/pulls/1707/commits"},"statuses":{"href":"https://api.github.com/repos/cockroachdb/docs/statuses/53dc9857ed0c7cae4d7176ae3eae33acccf1cb1c"}}}}
{"actor":{"display_login":"jseldess"}}