FirebirdSQL logo

Data Type Declaration Syntax

This section documents the syntax of declaring data types.Data type declaration commonly occurs in DDL statements, but also in CAST and EXECUTE BLOCK.

The syntax documented below is referenced from other parts of this language reference.

Scalar Data Types Syntax

The scalar data types are simple data types that hold a single value.For reasons of organisation, the syntax of BLOB types are defined separately in [fblangref50-datatypes-syntax-blob].

Scalar Data Types Syntax
<domain_or_non_array_type> ::=
    <scalar_datatype>
  | <blob_datatype>
  | [TYPE OF] domain
  | TYPE OF COLUMN rel.col

<scalar_datatype> ::=
    SMALLINT | INT[EGER] | BIGINT | INT128
  | REAL | FLOAT [(bin_prec)] | DOUBLE PRECISION
  | DECFLOAT [(dec_prec)]
  | BOOLEAN
  | DATE
  | TIME [{WITHOUT | WITH} TIME ZONE]
  | TIMESTAMP [{WITHOUT | WITH} TIME ZONE]
  | {DECIMAL | DEC | NUMERIC} [(precision [, scale])]
  | {VARCHAR | {CHAR | CHARACTER} VARYING} (length)
    [CHARACTER SET charset]
  | {CHAR | CHARACTER} [(length)] [CHARACTER SET charset]
  | {NCHAR | NATIONAL {CHARACTER | CHAR}} VARYING (length)
  | {NCHAR | NATIONAL {CHARACTER | CHAR}} [(length)]
  | BINARY [(length)]
  | {VARBINARY | BINARY VARYING} (length)
Table 1. Arguments for the Scalar Data Types Syntax
Argument Description

domain

Domain (only non-array domains)

rel

Name of a table or view

col

Name of a column in a table or view (only columns of a non-array type)

bin_prec

Binary precision, default is 24.

1 - 24: 32-bit single precision
25 - 53: 64-bit double precision (synonym of DOUBLE PRECISION)

dec_prec

Decimal precision of DECFLOAT, either 16 or 34;Default is 34

precision

Numeric precision in decimal digits.From 1 to 38

scale

Scale, or number of decimals.From 0 to 38.It must be less than or equal to precision

length

The maximum length of a string, in characters, or — for BINARY and VARBINARY — bytes;optional for fixed-width character types, defaults to 1

charset

Character set

domain_or_non_array_type

Non-array types that can be used in PSQL code and casts