I am trying to query my SQL CE to retrieve database meta data - at the moment I am trying to fetch the index data using:
我正在尝试查询我的SQL CE以检索数据库元数据 - 目前我正在尝试使用以下方法获取索引数据:
select * from information_schema.indexes
select * from information_schema.indexes
However this query is going to be run programatically - and needs to return the needed columns in the right order. Therefore, I have built the following select statement:
但是,此查询将以编程方式运行 - 并且需要以正确的顺序返回所需的列。因此,我构建了以下select语句:
select Table_Name, Table_Schema, Index_Name, Clustered, Unique, Column_Name from information_schema.indexes
从information_schema.indexes中选择Table_Name,Table_Schema,Index_Name,Clustered,Unique,Column_Name
However, the words Clustered
and Unique
are reserved keywords and they cannot be used in a select statement. Doing so, I get the following error: There was an error parsing the query. [Token line number: 1,Token line offset: 45, 0,Token in error: Clustered,,]
但是,“Clustered”和“Unique”这两个词是保留关键字,不能在select语句中使用。这样做,我收到以下错误:解析查询时出错。 [令牌行号:1,令牌行偏移量:45,0,错误令牌:集群,]
I found a similar issue here (Using SQL keyword in title of table or column) but the solution does not seem to work with SQL CE (wrapping column name in back-ticks).
我在这里发现了一个类似的问题(在表或列的标题中使用SQL关键字)但该解决方案似乎不适用于SQL CE(在后面的标记中包装列名)。
Any ideas how I can actually select data from keyword columns in SQL CE?
有什么想法我如何从SQL CE中的关键字列中实际选择数据?
2 个解决方案
#1
2
That post is about doing this in MySQL. SQL Server (of which SQL CE is a derivative) uses square brackets as field identifiers, so surround the field(s) in square brackets [].
这篇文章是关于在MySQL中这样做的。 SQL Server(其中SQL CE是派生的)使用方括号作为字段标识符,因此将字段括在方括号[]中。
select
Table_Name,
Table_Schema,
Index_Name,
[Clustered],
[Unique],
Column_Name
from information_schema.indexes
#2
1
Surround with square brackets:
方括号环绕:
select [Table_Name], [Table_Schema], [Index_Name], [Clustered], [Unique], [Column_Name] from [information_schema].[indexes]
#1
2
That post is about doing this in MySQL. SQL Server (of which SQL CE is a derivative) uses square brackets as field identifiers, so surround the field(s) in square brackets [].
这篇文章是关于在MySQL中这样做的。 SQL Server(其中SQL CE是派生的)使用方括号作为字段标识符,因此将字段括在方括号[]中。
select
Table_Name,
Table_Schema,
Index_Name,
[Clustered],
[Unique],
Column_Name
from information_schema.indexes
#2
1
Surround with square brackets:
方括号环绕:
select [Table_Name], [Table_Schema], [Index_Name], [Clustered], [Unique], [Column_Name] from [information_schema].[indexes]