大网数据广告活动
磁盘与文件系统

JetSetDatabaseSize Function

· 52CE 我爱测

Learn more about: JetSetDatabaseSize Function

Applies to: Windows | Windows Server

JetSetDatabaseSize Function

The JetSetDatabaseSize function sets the size of an unopened database file.

    JET_ERR JET_API JetSetDatabaseSize(
      __in          JET_SESID sesid,
      __in          JET_PCSTR szDatabaseName,
      __in          unsigned long cpg,
      __out         unsigned long* pcpgReal
    );

Parameters

sesid

Identifies the database session context to use for the API call.

szDatabaseName

Identifies the name of the database file whose size is to be altered.

cpg

Specifies the desired size of the database, in pages.

pcpgReal

Pointer to a number that receives the size of the database, in pages, after the API call. If the API call was unsuccessful, the contents of pcpgReal are undefined.

Return Value

This function returns the JET_ERR datatype with one of the following return codes. For more information about the possible ESE errors, see Extensible Storage Engine Errors and Error Handling Parameters.

Return code Description
JET_errSuccess The operation completed successfully.
JET_errDatabaseInconsistentJET_errDatabaseDirtyShutdown JET_errDatabaseInconsistent and JET_errDatabaseDirtyShutdown are the same numeric value. The database whose size is to be adjusted must be in a clean shutdown, known as a consistent state. An inconsistent database is not corrupted, but it requires log files to be replayed.
JET_errDatabaseInvalidPath szDatabaseName must not be an empty, non-NULL string.
JET_errDiskFull There is insufficient free space on the volume to perform the grow operation. JetSetDatabaseSize may also return many file-related errors, including, but not limited to:<ul><li>JET_errDiskIO</li><li>JET_errFileNotFound</li><li>JET_errInvalidPath</li><li>JET_errFileAccessDenied</li><li>JET_errOutOfFileHandles</li></ul>
JET_errInvalidParameter One of the reasons this error may be returned is if cpg does meet the minimum database size. The current minimum database size is 256 pages.
JET_errOutOfMemory The system is low on memory resources.
Remarks

If JetSetDatabaseSize is called prior to inserting large amounts of data, the database file will be grown in one operation. This will reduce the likelihood of the database file becoming fragmented at the file system level, and also reduce the number of times the database file has to be grown. Growing the database file once can be faster than growing it several times.

Only growing the file is currently supported. To shrink a file, use the defragmentation feature of the esentutl.exe utility program.

If cpg is smaller than the current size of the database, the operation will be ignored. If cpg is less than the minimum database size (currently 256 pages), it will return JET_errInvalidParameter.

To set the size of a database that is opened, see JetGrowDatabase.

The file size may not match the number of pages returned in pcpgReal. There are two additional reserved pages that may not be counted in pcpgReal.

Requirements
Requirement Value
Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Header Declared in Esent.h.
Library Use ESENT.lib.
DLL Requires ESENT.dll.
Unicode Implemented as JetSetDatabaseSizeW (Unicode) and JetSetDatabaseSizeA (ANSI).
See Also

JET_ERR
JET_GRBIT
JET_SESID
JET_TABLEID
JET_OBJECTINFO
JET_OBJECTLIST
JetGrowDatabase

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 04/11/2016
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。