Compartir a través de


EDB Data Types and Size Limits (Windows CE 5.0)

Send Feedback

EDB has been designed to support many of the features of both CEDB and Microsoft SQL Server 2005 Mobile Edition (SQL Server CE). Because of this, EDB supports more data types than CDEB, but it also has some size limits not imposed by CEDB.

Supported Data Types

EDB supports 13 data types, including all 9 data types supported by CEDB plus 4 additional data types. The following table shows the data types supported by EDB. The last 4 data types in the table are new to EDB, and are described in more detail in later sections of this topic.

Data Type Description
CEVT_BLOB A BLOB structure
CEVT_BOOL A Boolean value
CEVT_FILETIME A FILETIME structure
CEVT_I2 A 16-bit signed integer
CEVT_I4 A 32-bit signed integer
CEVT_LPWSTR A null-terminated string
CEVT_R8 A 64-bit float
CEVT_UI2 A 16-bit unsigned integer
CEVT_UI4 A 32-bit unsigned integer
CEVT_STREAM (EDB only) A large binary stream of data
CEVT_RECID (EDB only) A 128-bit GUID uniquely identifying a record
CEVT_AUTO_I4 (EDB only) A 32-bit signed integer (auto-generated)
CEVT_AUTO_I8 (EDB only) A 64-bit signed integer (auto-generated)

The CEVT_STREAM Data Type

A CEVT_STREAM data type is useful for storing larger data items, such as images or e-mail attachments, because stream data is stored on its own set of data pages within the database, not in the row. The CEVT_STREAM data type stores up to 256 bytes within a row; once the first 256 bytes are used, the stream data is automatically stored outside of the row.

Therefore, although EDB limits the maximum record size to 8 kilobytes (KB), the maximum size of a stream is not affected by this limit. It is, however, limited to 32 megabytes (MB), which is one-half the maximum size of a volume.

Using the CEVT_STREAM Data Type

Consider the following when working with the CEVT_STREAM data type:

  • The CEVT_STREAM data type requires more overhead than the other data types. Because most stream data is stored external to the physical row, retrieval of stream data requires extra page accesses.
  • Stream data can be read or written as a single entity or in smaller pieces. For more information on reading and writing stream data, see "Accessing the CEVT_STREAM Data Type" later in this topic.
  • Because stream data is stored outside of the row, it is possible for other operations to modify or delete the row while portions of the stream data are being accessed or modified. You can avoid this in two ways: by using transaction isolation levels, or by writing or reading the stream data as a single entity.
  • Stream data is not compressed by default, but it can be compressed by using the DB_PROP_COMPRESSED flag. The stream's compression cannot be altered using the CeSetDatabaseInfo function. Once the stream is compressed, you must access it in a single block.
  • The CEVT_STREAM data type cannot be used in a sort order.

Accessing the CEVT_STREAM Data Type

As with the CEVT_BLOB data type, you can read data from and write data to the CEVT_STREAM data type by using the CeReadRecordPropsEx and CeWriteRecordProps functions. However, when you read and write a stream using these functions, all of the stream data must be in memory at once (in the CEPROPVAL::val.blob member), which can be very inefficient if the stream is large. For this reason, four exposed stream functions let you efficiently access a large stream of data in smaller pieces: CeOpenStream, CeStreamRead, CeStreamWrite, and CeStreamSeek. Two other stream functions are also available when working with stream data: CeStreamSaveChanges and CeStreamSetSize.

Note   If the stream data is compressed, you cannot use the stream functions; you must use the CeReadRecordPropsEx and CeWriteRecordProps functions.

Reading Stream Data when CEDB_AUTOINCREMENT is Enabled

When you open a database using the CeOpenDatabaseInSession function, you can specify the CEDB_AUTOINCREMENT flag. If you set the CEDB_AUTOINCREMENT flag, then the current seek position is automatically incremented with each call to the CeReadRecordPropsEx function, whether you are reading stream data or non-stream data. However, the seek position is not incremented with each call to the CeStreamRead function. This can lead to unexpected behavior. To avoid this, your application should make any calls to the CeStreamRead function before calls to the CeReadRecordPropsEx function when you are using CEDB_AUTOINCREMENT.

The CEVT_RECID Data Type

The CEVT_RECID (record ID) data type provides an auto-generated, 128-bit CEGUID row identifier. These identifiers can be persisted and indexed. When using the CEVT_RECID data type consider the following rules:

  • You access the value of the CEVT_RECID typed property the same way that you access the value of a CEVT_BLOB typed property.
  • You can write an explicit CEGUID value to the CEVT_RECID property (column), but once the value is written, it cannot be modified.
  • A CEVT_RECID property cannot have null values.
  • The CEVT_RECID data type can be used in a sort order.

The CEVT_AUTO_I4 and CEVT_AUTO_I8 Data Types

The CEVT_AUTO_I4 and CEVT_AUTO_I8 data types provide auto-generated integers. The following numeric ranges apply to these data types:

Data type Range
CEVT_AUTO_I4 0 to 2^31 (a 32-bit integer)
CEVT_AUTO_I8 0 to 2^63 (a 64-bit integer)

When using the CEVT_AUTO_I4 and CEVT_AUTO I8 data types, consider the following rules:

  • The values for the CEVT_AUTO properties are written automatically and cannot be updated.
  • Only one CEVT_AUTO data type can be used in a database.
  • The CEVT_AUTO data types can be used in a sort order.

Volume and Data Type Size Limits

When comparing the capacities of EDB and CEDB, the most noticeable differences are in the maximum record size and the supported sizes for the CEVT_BLOB and CEVT_LPWSTR data types. By using the new CEVT_STREAM data type, which stores data outside of the row, the size limitations of EDB are easily overcome.

The following table shows the size limits for several data types of EDB, CEDB, and SQL Server Mobile databases:

Data type EDB CEDB SQL Server 2005 Mobile Edition
CEVT_BLOB 8,000 bytes 64 KB 1.07 GB
CEVT_LPWSTR 4,000 characters 64 KB Maps to nchar/nvarchar
CEVT_STREAM 32 MB (one-half of the maximum volume size) Not supported Maps to image/ntext

The following table shows the size limits for several features of EDB, CEDB, and SQL Server CE databases:

Feature EDB CEDB SQL Server 2005 Mobile Edition
Maximum volume size 64 MB 16 MB 2.14 GB
Maximum record size 8 KB (excluding stream data) 128 KB 4 KB
Maximum number of properties per database 1,024 No limit 255
Maximum property name length 128 characters Not supported 128 characters
Maximum volume name length (MAX_PATH - 13) characters MAX_PATH flag 128 characters
Maximum number of sort orders 16 4 249
Maximum number of properties in a sort order or index 16 3 10
Maximum key length in a sort order or index 512 bytes 512 bytes 510 bytes
Default lock escalation value 100 Not supported Not supported
Maximum number of concurrent transactions 255 Not supported Not supported
Maximum password length 40 characters Not supported 40 characters
Maximum number of open database handles 256 Not supported Not supported

Note that EDB restricts the size of CEVT_LPWSTR and CEVT_BLOB data types to 4,000 characters and 8,000 bytes, respectively, while CEDB supports data sizes up to 64 KB. However, with the addition of the new CEVT_STREAM data type, you can now store much larger data values. In addition, although EDB has a maximum record size that is much smaller than that of CEDB, stream data is stored external to the row and is therefore not subject to this limit.

See Also

CeOpenStream | CeStreamRead | CeStreamWrite | CeStreamSeek | CeStreamSaveChanges | CeStreamSetSize

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.