是否可以监视和记录针对 Access MDB 进行的实际查询?

发布于 2024-08-30 16:34:07 字数 107 浏览 0 评论 0 原文

是否可以监视 Access MDB 发生的情况(即正在对其执行哪些 SQL 查询),就像使用 SQL Server 的 SQL Profiler 一样?

我需要被调用的实际查询的日志。

Is it possible to monitor what is happening to an Access MDB (ie. what SQL queries are being executed against it), in the same way as you would use SQL Profiler for the SQL Server?

I need logs of actual queries being called.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

红颜悴 2024-09-06 16:34:07

答案取决于使用 MDB 的客户端所使用的技术。您可以在 HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\ODBC 中配置不同的跟踪设置 http://office.microsoft.com/en-us/access/HP010321641033.aspx。如果您使用 OLEDB 从 SQL Server 访问 MDB,则可以使用 DBCC TRACEON(请参阅 http ://msdn.microsoft.com/en-us/library/ms187329.aspx)。我可以继续,但首先您应该准确定义用于访问 MDB 的接口。

MDB是一个没有任何活动组件的文件,因此跟踪不能跟踪MDB本身,而只能跟踪DB接口。

更新:因为使用DAO(Jet Engine)和VB中的OLE DB,所以我建议您在HKEY_LOCAL_MACHINE \ SOFTWARE \ MICROSOFT \ JET \ 4.0 \ Engines \ Debug下创建JETSHOWPLAN注册表项,其值为“ON”(您必须创建调试子项)。例如 https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5064388.htmlhttp://msdn.microsoft.com/en-us/library/aa188211%28office.10% 29.aspx 并对应于 http://support.microsoft.com/kb/ 252883/en 允许跟踪 OLE DB 查询。如果此输出对您来说还不够,您还可以使用 HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\ODBC 中的 TraceSQLMode 和 TraceODBCAPI。在我的实践中,JETSHOWPLAN 为我提供了完美的信息。另请参阅 SHOWPLAN 推荐。

更新 2:对于较新版本的 Access(如 Access 2007),请使用 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Access Connectivity Engine\Engines 等密钥。工具 ShowplanCapturer(请参阅 http://www.mosstools.de/index.php?option=com_content&view=article&id=54&Item%20%20id=57,下载http://www.mosstools.de/download/showplan_v9.zip 也有英文版)也对您有帮助。

The answer depend on the technology used from the client which use MDB. There are different tracing settings which you can configure in HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\ODBC http://office.microsoft.com/en-us/access/HP010321641033.aspx. If you use OLEDB to access MDB from SQL Server you can use DBCC TRACEON (see http://msdn.microsoft.com/en-us/library/ms187329.aspx). I can continue, but before all you should exactly define which interface you use to access MDB.

MDB is a file without any active components, so the tracing can makes not MDB itself, but the DB interface only.

UPDATED: Because use use DAO (Jet Engine) and OLE DB from VB I recommend you create JETSHOWPLAN regisry key with the "ON" value under HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\JET\4.0\Engines\Debug (Debug subkey you have to create). This key described for example in https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5064388.html, http://msdn.microsoft.com/en-us/library/aa188211%28office.10%29.aspx and corresponds to http://support.microsoft.com/kb/252883/en allow trace OLE DB queries. If this output will be not enough for you you can additionally use TraceSQLMode and TraceODBCAPI from HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\ODBC. In my practice JETSHOWPLAN gives perfect information for me. See also SHOWPLAN commend.

UPDATED 2: For more recent version of Access (like Access 2007) use key like HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Access Connectivity Engine\Engines. The tool ShowplanCapturer (see http://www.mosstools.de/index.php?option=com_content&view=article&id=54&Item%20%20id=57, to download http://www.mosstools.de/download/showplan_v9.zip also in english) can be also helpful for you.

风情万种。 2024-09-06 16:34:07

如果您通过 ODBC 访问它,则可以打开 ODBC 日志记录。不过,这会让事情变慢很多。它不适用于任何其他数据接口。

另一个想法是使用Jet/ACE作为SQL Server中的链接服务器,然后使用SQL Profiler。但这将告诉您 SQL Server 处理的 SQL,而不是 Jet/ACE 处理的内容。它可能足以满足您的目的,但我认为这对于 Jet/ACE 来说不是一个很好的诊断。

编辑:

在评论中,原始海报提供了这个相当重要的信息:

我试图监控的应用程序
已编译并在客户处
前提。我正在尝试监控什么
查询它正在尝试针对
MDB。我无法修改该应用程序。
我正在尝试做 SQL Profiler 的事情
对于 SQL Server 来说就可以了。

在这种情况下,我认为您可以这样做:

  1. 将原始 MDB 重命名为其他名称。

  2. 使用 SQL Server 链接服务器连接到重命名的 MDB 文件。

  3. 使用原始 MDB 的名称创建一个新的 MDB,并使用 ODBC 链接到 SQL Server。

    使用原始

结果将是一个 MDB 文件,其中包含与原始表相同的表,但它们不是本地的,而是链接到 SQL Server。在这种情况下,所有访问都将通过 SQL Server,并且可以使用 SQL Profiler 查看。

我不知道这会对性能产生什么影响,或者是否会破坏原始应用程序中的任何数据检索。如果该应用程序使用表类型记录集或 SEEK,那么,是的,它会崩溃。但这是我能看到的记录日志的唯一方法。

鉴于没有单一服务器进程管理对数据存储的访问,Jet/ACE 没有日志记录也就不足为奇了。

If you're accessing it via ODBC, you can turn on ODBC logging. It will slow things down a lot, though. And it won't work for any other data interface.

Another thought is using Jet/ACE as a linked server in SQL Server, and then using SQL Profiler. But that's going to tell you the SQL that SQL Server processed, not what Jet/ACE processed. It may be sufficient for your purposes, but I don't think it would be a good diagnostic for Jet/ACE.

EDIT:

In a comment, the original poster has provided this rather crucial information:

The application I am trying to monitor
is compiled and at a customer's
premises. I am trying to monitor what
queries it is attempting against an
MDB. I cannot modify the application.
I am trying to do what SQL Profiler
would do for a SQL Server.

In that case, I think that you could do this:

  1. rename the original MDB to something else.

  2. use a SQL Server linked server to connect to the renamed MDB file.

  3. create a new MDB with the name of the original MDB and link to the SQL Server with ODBC.

The result will be an MDB file that has the same tables in it as the original, but they are not local, but links to the SQL Server. In that case, all access will be going through the SQL Server and can be viewed with SQL Profiler.

I don't have a clue what this would do to performance, or if it would break any of the data retrieval in the original app. If that app uses table-type recordsets or SEEK, then, yes, it will break. But this is the only way I can see to get logging.

It shouldn't be surprising that there is no logging for Jet/ACE, given that there is no single server process managing access to the data store.

前事休说 2024-09-06 16:34:07

请记住,硬盘上的文件只是一个 Windows 文件。因此,基于服务器的系统与简单的文本文件、Power Point 文件或在本例中是位于驱动器上的 mdb 文件的系统之间存在很大差异。

但是,您可以让 jet 引擎通过 showplan 显示其查询优化。

如何执行此操作的说明如下:

http://www.databasejournal.com/features/msaccess/article.php/3658041/Queries-On-Steroids--Part-IV.htm

上面的文章还展示了如何访问jet disk阅读统计数据,我还发现这对于优化事物非常有用。

只要记住在不使用数据引擎日志系统时关闭它,因为它会创建巨大的日志文件......

Keep in mind that the file sitting on your hard drive is simply a windows file. So, there is a big difference between a server based system and that of a simple text file, or Power Point file, or in this case a mdb file just sitting on the drive.

However you can get the jet engine to display its query optimizeing via showplan.

How to do this is explained here:

http://www.databasejournal.com/features/msaccess/article.php/3658041/Queries-On-Steroids--Part-IV.htm

The above article also shows how to access the jet disk read statistics, which I also find extremely useful for optimizing things.

Just remember to turn off that data engine logging system when you’re not using it as it creates huge log files…

凉薄对峙 2024-09-06 16:34:07

您可以基于“事务”对象编写自己的探查器,该对象将集中发送到数据库的所有指令,您最终会在访问数据库中使用“transaction.execute”方法和事务表。该表可用于收集交易指令、开始时间、结束时间、发送指令的用户等。

you could write your own profiler, based on a "transaction" object that will centralize all instructions sent to the database, You'll end up somewhere with a "transaction.execute" method, and a transaction table in your access db. This table can then be used to collect transaction's instructions, start time, end time, user sending the instruction, etc.

日记撕了你也走了 2024-09-06 16:34:07

我建议将表扩大到 SQL Server。 SQL Server 组中有一个工具比 Access 附带的升迁向导更好。
SQL Server Access 迁移助手(SSMA 访问)

另请参阅我的来自 Microsoft Access 提示的关于 SQL Server 升迁的随机想法页面

I'd suggest upsizing the tables to SQL Server. There is a tool from the SQL Server group that is better than the Upsizing Wizard that is included with Access.
SQL Server Migration Assistant for Access (SSMA Access)

Also see my Random Thoughts on SQL Server Upsizing from Microsoft Access Tips page

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文