Data types

The database has defined data types that express the nature of the data. We can store text (for example, VARCHAR, VARCHAR2), or numbers (for example, INTEGER, NUMBER), date (for example, DATE, TIMESTAMP), etc.

Each data type has its limitations. When defining a data type, carefully consider which is most appropriate. This is so that we do not waste space by, for example, inserting only one character value into the VARCHAR2 data type.

For a basic overview, I will use the official Oracle documentation:

 

Image is taken from Docs.oracle source.

Example1:

We want to create a table and define a field named Product. This field can have the following values: T, W, P, Q.

You could define the Product field with the VARCHAR data type, as it has a capacity of 0 to 65535. However, it is much better to use the CHAR data type.

Leave a Comment

Your email address will not be published. Required fields are marked *