this chapter explains the different datatypes of hsqldb. hsqldb server offers six categories of data types.
exact numeric data types
| data type | from | to |
|---|---|---|
| bigint | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 |
| int | -2,147,483,648 | 2,147,483,647 |
| smallint | -32,768 | 32,767 |
| tinyint | 0 | 255 |
| bit | 0 | 1 |
| decimal | -10^38 +1 | 10^38 -1 |
| numeric | -10^38 +1 | 10^38 -1 |
| money | -922,337,203,685,477.5808 | +922,337,203,685,477.5807 |
| smallmoney | -214,748.3648 | +214,748.3647 |
approximate numeric data types
| data type | from | to |
|---|---|---|
| float | -1.79e + 308 | 1.79e + 308 |
| real | -3.40e + 38 | 3.40e + 38 |
date and time data types
| data type | from | to |
|---|---|---|
| datetime | jan 1, 1753 | dec 31, 9999 |
| smalldatetime | jan 1, 1900 | jun 6, 2079 |
| date | stores a date like june 30, 1991 | |
| time | stores a time of day like 12:30 p.m. | |
note − here, datetime has 3.33 milliseconds accuracy whereas small datetime has 1- minute accuracy.
character strings data types
| data type | description |
|---|---|
| char | maximum length of 8,000 characters (fixed length non-unicode characters) |
| varchar | maximum of 8,000 characters (variable-length non-unicode data) |
| varchar(max) | maximum length of 231 characters, variable-length non-unicode data (sql server 2005 only) |
| text | variable-length non-unicode data with a maximum length of 2,147,483,647 characters |
unicode character strings data types
| data type | description |
|---|---|
| nchar | maximum length of 4,000 characters (fixed length unicode) |
| nvarchar | maximum length of 4,000 characters (variable length unicode) |
| nvarchar(max) | maximum length of 231 characters (sql server 2005 only),(variable length unicode) |
| ntext | maximum length of 1,073,741,823 characters (variable length unicode) |
binary data types
| data type | description |
|---|---|
| binary | maximum length of 8,000 bytes (fixed length binary data) |
| varbinary | maximum length of 8,000 bytes (variable length binary data) |
| varbinary(max) | maximum length of 231 bytes (sql server 2005 only), (variable length binary data) |
| image | maximum length of 2,147,483,647 bytes (variable length binary data) |
misc data types
| data type | description |
|---|---|
| sql_variant | stores values of various sql server-supported data types, except text, ntext, and timestamp |
| timestamp | stores a database-wide unique number that gets updated every time a row gets updated |
| uniqueidentifier | stores a globally unique identifier (guid) |
| xml | stores xml data. you can store xml instances in a column or a variable (sql server 2005 only) |
| cursor | reference to a cursor object |
| table | stores a result set for later processing |