如何更新记录的所有列而不必列出每一列 [英] How to UPDATE all columns of a record without having to list every column

查看:26
本文介绍了如何更新记录的所有列而不必列出每一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出一种无需列出需要更新的每个列名即可更新记录的方法.

I'm trying to figure out a way to update a record without having to list every column name that needs to be updated.

例如,如果我可以使用类似于以下内容的内容就好了:

For instance, it would be nice if I could use something similar to the following:

// the parts inside braces are what I am trying to figure out
UPDATE Employee
SET {all columns, without listing each of them} 
WITH {this record with id of '111' from other table}
WHERE employee_id = '100'

如果可以这样做,编写此类查询的最直接/最有效的方法是什么?

If this can be done, what would be the most straightforward/efficient way of writing such a query?

推荐答案

这是不可能的.

您尝试做的不是 SQL 规范的一部分,并且不受任何数据库供应商的支持.参见MySQL的SQL UPDATE语句规范,PostgresqlMSSQL, Oracle, FirebirdTeradata.每一个都只支持以下语法:

What you're trying to do is not part of SQL specification and is not supported by any database vendor. See the specifications of SQL UPDATE statements for MySQL, Postgresql, MSSQL, Oracle, Firebird, Teradata. Every one of those supports only below syntax:

UPDATE table_reference
   SET column1 = {expression} [, column2 = {expression}] ...
[WHERE ...]

这篇关于如何更新记录的所有列而不必列出每一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆