如何插入名称为 sql 关键字的列 [英] How to INSERT to a column whose name is a sql keyword

查看:19
本文介绍了如何插入名称为 sql 关键字的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个存储键值对的表,因此我创建了一个表,其中包含一个名为Key"的列和一个名为Value"的列.

I need a table that stores key-value pairs, so I created one with a column called "Key" and a column called "Value".

这失败了:

insert into mykeyvalues (Key,Value) values ('FooKey', 'FooValue')

关键字'key'附近的语法不正确."

"Incorrect syntax near the keyword 'key'."

也许我不应该称它为Key",但我只是想知道是否可以使用名称为 sql 关键字的列?

Maybe I shouldn't call it "Key", but I just wonder if it is possible to work with a column whose name is a sql keyword?

谢谢

推荐答案

你可以用 [ ] 括号括起来这样的列名.因此:

You can surround column names like that with [ ] brackets. Therefore:

insert into mykeyvalues ([Key],[Value]) values ('FooKey', 'FooValue')

这篇关于如何插入名称为 sql 关键字的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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