表字段可以包含连字符吗?

Can a table field contain a hyphen?(表字段可以包含连字符吗?)
本文介绍了表字段可以包含连字符吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 MySQL 表中有一个表,字段名为product",我想将其重命名为ds-product".

I have a table in a MySQL table with a fieldname 'product', and want to rename it to 'ds-product'.

我使用的 CMS 类型系统使用表单域的 id 作为要插入的表字段的名称.

The CMS type system I am using uses the id of formfields as the name of the table field to insert into.

对于大多数情况,这可以正常工作,但对于特定字段,它会在我提供的任何 ID 前面加上ds-",因此我必须使表字段名称匹配.

For most this works fine, but for a particular field it prepends 'ds-' to whatever ID I give it, so I must make the table field name match.

但是,在尝试进行查询时,我收到错误

However, when trying to do a query I get the error that

字段列表"中的未知列sales.ds"

Unknown column 'sales.ds' in 'field list'

有什么办法可以让我拥有一个名为 ds-product 的字段吗?

Is there any way I can have a field called ds-product?

推荐答案

是的,如果使用分隔标识符,则可以使用标点符号、空格、国际字符和 SQL 保留字:

Yes, you can use punctuation, white space, international characters, and SQL reserved words if you use delimited identifiers:

SELECT * FROM `my-table`;

在 MySQL 中,使用反引号.在标准 SQL 中,使用双引号.

In MySQL, use the back-ticks. In standard SQL, use double-quotes.

或者如果你使用 MySQL 你可以设置 ANSI_QUOTES SQL 模式:

Or if you use MySQL you can set the ANSI_QUOTES SQL mode:

SET SQL_MODE = ANSI_QUOTES;
SELECT * FROM "my-table";

这篇关于表字段可以包含连字符吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
SQL query to group by day(按天分组的 SQL 查询)
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
Include missing months in Group By query(在 Group By 查询中包含缺失的月份)