仅将一个值插入表的单个列中 [英] Inserting only one value into a single column of a table
本文介绍了仅将一个值插入表的单个列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好。我在标题中提到的问题是如何只将一个值插入表的一列。 INSERT语句似乎不够,因为它总是逐行插入并用空值填充其余列。
提前致谢。
(PS我知道动态SQL,所以你的答案可以包括它。)
Hi. My question as said in the title is how to insert only one value into a single column of a table. INSERT statement doesn't seem to suffice since it always does its insertion row by row and fills the rest of the columns with null values.
Thanks in advance.
(P.S. i know dynamic SQL so your answer can include it if you want.)
推荐答案
你不能插入一个列,只能插入一整行。
如果表中的所有列都允许为null,你可以使用这样的查询
You cannot insert a single column, only a full row.
If all your columns int the table allow null, you can use a query like this
INSERT INTO table_name (single_column) VALUES (some_value);
否则你只能更新现有的行和这可以针对单个列进行。
Otherwise you can only update an existing row and this can be done for a single column.
UPDATE table_name SET single_column = some_value WHERE primary_key = a_value;
(或自然键)
也许你自己做一些阅读。
SQL教程 [ ^ ]
这篇关于仅将一个值插入表的单个列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文