Partager via


EDB Data Types and Size Limits (Windows Embedded CE 6.0)

1/6/2010

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

Supported Data Types

The following table shows the data types supported by EDB.

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, An auto-generated 32-bit signed integer.

CEVT_AUTO_I8

EDB only. An autt-generated 64-bit signed integer.

CEVT_STREAM

CEVT_STREAM stores larger data items, such as images or e-mail attachments. Stream data is stored on its own set of data pages in the database, not in a record. CEVT_STREAM stores up to 256 bytes in a record. Once 256 bytes are used, the stream data is automatically stored outside the record.

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

Using CEVT_STREAM

Consider the following when working with CEVT_STREAM:

  • CEVT_STREAM requires more overhead than other data types. Because most stream data is stored outside the physical record, retrieval of stream data requires extra page accesses.
  • Stream data can be read or written as a single entity or in smaller pieces.
  • Because stream data is stored outside the record, it is possible for other operations to modify or delete the record while portions of the stream data are being accessed or modified. You can avoid this 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. Stream compression cannot be altered using the CeSetDatabaseInfoEx (EDB) function. Once the stream is compressed, you must access it in a single block.
  • CEVT_STREAM cannot be used in a sort order.

Accessing CEVT_STREAM

As with the CEVT_BLOB data type, you can read data from and write data to CEVT_STREAM by using the CeReadRecordPropsEx (EDB) and the CeWriteRecordProps (EDB) functions. However, when you read and write a stream using these functions, all 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, the following stream functions enable efficient access to a large stream of data in smaller pieces:

The following stream functions are also available when working with stream data:

Note

If the stream data is compressed, you cannot use the stream functions. You must use the CeReadRecordPropsEx (EDB) and the CeWriteRecordProps (EDB) functions.

Reading Stream Data when CEDB_AUTOINCREMENT is Enabled

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

CEVT_RECID

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

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

CEVT_AUTO_I4 and CEVT_AUTO_I8

The CEVT_AUTO_I4 and CEVT_AUTO_I8 data types provide auto-generated integers. The following table shows the numeric ranges that apply to these data types.

Data type Range

CEVT_AUTO_I4

Zero through 2 to the 31st power, a 32-bit integer.

CEVT_AUTO_I8

Zero through 2 to the 63st power, a 64-bit integer.

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

  • The values for properties of CEVT_AUTO type 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 CEVT_STREAM data type, which stores data outside the record, record size limitations are easily overcome in EDB.

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

Data type EDB CEDB SQL Server 2005 Compact Edition

CEVT_BLOB

8000 bytes

64 KB

1.07 GB

CEVT_LPWSTR

4000 characters

64 KB

Maps to nchar/nvarchar

CEVT_STREAM

32 MB, half 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 Compact Edition databases:

Feature EDB CEDB SQL Server 2005 Compact 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

1024 properties

No limit

255 properties

Maximum property name length

128 characters

Not supported

128 characters

Maximum volume name length

(MAX_PATH - 13) characters

Value of the MAX_PATH flag

128 characters

Maximum number of sort orders

16 sort orders

4 sort orders

249 sort orders

Maximum number of properties in a sort order or index

16 properties

3 properties

10 properties

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

EDB restricts the size of CEVT_LPWSTR and CEVT_BLOB data types to 4000 characters and 8000 bytes, respectively, whereas 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 record, and is therefore not subject to this limit.

See Also

Reference

CeOpenStream (EDB)
CeStreamRead (EDB)
CeStreamWrite (EDB)
CeStreamSeek (EDB)
CeStreamSaveChanges (EDB)
CeStreamSetSize (EDB)

Other Resources

EDB Database Support