OLEDB:在不选择任何行的情况下获取 SQL Server CE 表的列元数据的最快方法是什么?
我必须将 OLE DB 与 SQL Server CE 一起使用。我的任务是获取表中所有列的元数据。
一种方法是选择任意行的所有字段,然后从结果行集中获取 IColumnInfo
。然而,这是以选择行为代价来完成的。
我的问题 - 这是最快的方法还是有更好的方法来获取表中所有列的 DBCOLUMNINFO
对象?
I have to use OLE DB with an SQL Server CE. My task is to obtain the metadata on all the columns in a table.
One way to do it is select all the fields of any row and then obtain IColumnInfo
from the resulting row set. However, this is done at the cost of selecting a row.
My question - is it the fastest way or is there a better way to get hold on the DBCOLUMNINFO
objects for all the columns in a table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 INFORMATION_SCHEMA 上使用 SELECT 语句来提取特定表的列信息:
但是,在 OLEDB 中,有一个 IDBSchemaRowset,它可以快得多。我整理了一个小型 C++ 代码示例,该示例显示了打开 OLEDB 连接 (OpenDatabase) 并使用 IRowset (GetSchemaColumns) 提取列信息。您需要添加处理 IRowset 返回的结果(运行):
You can use a SELECT statement on the INFORMATION_SCHEMA to extract COLUMN information for a particular table:
However, in OLEDB there's an IDBSchemaRowset which can be a lot faster. I've put together a small C++ code sample that shows opening an OLEDB connection (OpenDatabase) and extracting column information using IRowset (GetSchemaColumns). You need to add processing the results from IRowset returned (Run):
如果您想避免选择行,请使用
where 1 = 0
作为 where 子句。您还可以使用 INFORMATION_SCHEMA 表。
Microsoft 文档:信息架构 (SQL Server Compact)
If you want to avoid selecting rows, use
where 1 = 0
as your where clause.You could also use the INFORMATION_SCHEMA tables.
Microsoft docs: Information Schema (SQL Server Compact)