Type
DATE
The DATE type is a data type that represents a specific date and time to the nearest second. It has the same range of representation as TIMESTAMP(0).
DATE
Expresses year, month, day, hour, minute, and second.
Years can be expressed from 4,713 BC~ to 294,276 AD.
Time is expressed in 24-hour increments.
CREATE TABLE T (a date);
INSERT INTO T VALUES ('4713-01-01 01:11:30 BC');
INSERT INTO T VALUES ('2023-03-19 13:29:30');
VARCHAR2
Like the CHARACTER VARYING type, the VARCHAR2 type also has a variable length, where the string length is not constant.
VARCHAR2[(size)]
A string can be declared up to 10,485,760 bytes (=10 MB). If the length of the converted string exceeds that size, an error is raised.
If the size of the string is not specified, it behaves like the Postgresql native type TEXT.
The length of the string can be specified in bytes.
Always use single quotes (' ') to represent values of type VARCHAR2 in SQL statements.
The following example illustrates the VARCHAR2 type.
EMP_NAME VARCHAR2(10)
As shown in the example above, the EMP_NAME column has a string length of 10 bytes. For example, if the string 'Peter' is entered, the string 'Peter' is stored. In other words, the string length of the EMP_NAME column is declared to be 10 bytes, but the actual stored string length is 5 bytes.
As you can see, the VARCHAR2 type has a length equal to the length of the entered string within the range of the declared string length.
NVARCHAR2
The NVARCHAR2 type is for storing Unicode strings. It is characterized by having a variable length, where the length of the string is not constant.
NVARCHAR(size)
It is basically similar to the VARCHAR2 type, but the length of the string is in characters. The length of the types stored in the database depends on the multilingual character set. For example, it can be up to three times the size in UTF8 and up to twice the size in UTF16.
The maximum length of a string of type NVARCHAR2 is 10,485,760 characters.
Always use single quotes (' ') to represent values of type NVARCHAR2 in SQL statements.
Last updated