LONG
LONG is a datatype in SQL that's used to store variable length character strings. It can store up to two gigabytes of character data in a database. However, LONG columns have many restrictions and are used less frequently compared to LOBs (Large Objects). Oracle recommends using LOB or VARCHAR2 types instead of LONG for new development work.
Example
Output
Explanation
In the above example, a table ‘Example’ is created with ID as NUMBER and LongColumn as LONG. It then inserts a row with the ID as 1, and LongColumn as ‘Long text data type example.’. Lastly, it fetches the data from the table. The returned result is the data where ID is 1, and LongColumn is ‘Long text data type example.’.
Example
Output
Explanation
This example illustrates the use of the data type VARCHAR(MAX), which allows for storage of variable-length non-Unicode character data up to 2 gigabytes of text data. It declares a variable @LongExample
as VARCHAR(MAX) and sets it to a string of 8001 characters long. The SELECT
statement is then used to return the length of the string, which is 8001.