如果该列不存在,如何将值插入表中的特定列 [英] How can insert value into a table for a particular column if that coulumn doesn't exist

查看:186
本文介绍了如果该列不存在,如何将值插入表中的特定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设不存在一个特定的列.但是我想使用insert querry插入该列的值而不在该表中添加该特定的列.有什么办法吗?

Suppose one particular column is not present.But I want to use insert querry to insert the value for that column without adding that particular column in that table.Is there any way?

推荐答案

我认为以任何正常方式都是不可能的,您可以将不存在的列的数据添加到使用某种分隔符(即分号)分隔的现有列中.
但是,恐怕这不是SQL中的最佳实践.如果您不希望在表中添加其他列,则可以始终使用所需的列添加新表,然后通过外键将其连接到现有表.
I think that is not possible in any normal way, you could add the data for the unpresent column to an existing column separated with some kind of separator, i.e. a semicolon.

But i''m afraid that is not considered best practice in SQL. If you don''t wish to add another column to the table you could always add a new table with the column you want and connect it to the existing table via foreign key.


有防止数据库更改的几种方法.但是,如果您省略了数据库更改,则需要更新代码末尾.

您可以使用Delimeter&将其新值附加到任何其他现有列中.然后通过拆分在代码中获取该值.

或者您可以使用xml格式的列(如果您假设将来会有更多的列).您只需要在xml&中添加一个节点继续将xml解析为代码,以获取这些即将到来的列值.


也可以有其他几种方式.
there are several ways to prevent changes in database. but if you omit db changes you require to update your code end.
i.e.
you may append your new value in to any other existing column using delimeter & then get that value in code by splitting it.

or you may use xml format column (if you assume to have increasing columns in future). you only need to add a node in xml & keep parsing xml into code to get those upcoming columns values.


there can be several other ways too.


这篇关于如果该列不存在,如何将值插入表中的特定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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