Javatpoint Logo
Javatpoint Logo

PostgreSQL Text

In this section, we are going to understand the working of PostgreSQL Text data types, which allows us to store the character of unlimited length. And we also see examples of the text data type.

What is PostgreSQL Text datatype?

In PostgreSQL, the text data type is used to keep the character of infinite length. And the text data type can hold a string with a maximum length of 65,535 bytes.

In other words, we can say that the PostgreSQL Text data type uses the character data type, which is signified as text, and the representation of the Varchar without Size n and Text are equivalent.

Syntax of PostgreSQL Text data type

The syntax of the PostgreSQL Text data type is as follows:

Examples of PostgreSQL TEXT data type

Let us see different examples to understand how the PostgreSQL Text data type works.

Example1

For this, we will create one new table name Text_demo table with the help of the CREATE command and inserting some values by using the INSERT command.

We are going to create Text_demo tables into the Organization database by using the CREATE command:

Output

After successful execution of the above command, the Text_demo table has been created, as shown in the below image:

PostgreSQL Text

Once the Text_demo table has been generated, we will insert some values into it using the INSERT command.

Output

On implementing the above command, we will get the following result, which displays that the value has been inserted successfully into the Text_demo table.

PostgreSQL Text

As we can see in the above screenshot, we inserted the values for both the columns A and B for the Text datatype successfully.

After creating and inserting the Text_demo table's values, we will use the SELECT command to return all rows of the Text_demo table:

Output

After implementing the above command, we will get the following result where we can see that both the values of Column A and Column B have been entered successfully into the Text_demo table.

PostgreSQL Text

Example2

Let us see one more example, to learn the text data type in details. So, we are creating one new table as Text_demo2 with CREATE command's help and inserting some values by using the INSERT command.

We are going to create Text_demo2 into a similar database as above that is Organization by using the CREATE command:

Output

The Text_demo2 table has been successfully created after executing the above command, as shown in the below screenshot:

PostgreSQL Text

Once the Text_demo2 table has been generated, we can insert some values into it using the INSERT command.

Output

After executing the above command, we will get the following result, which displays that the value has been inserted successfully into the Text_demo2 table.

PostgreSQL Text

As we can see in the above screenshot, the multiple values have been inserted successfully for both A and B columns into the Text_demo2 table.

After creating and inserting the Text_demo2 table's values, we will use the SELECT command to return all rows of the Text_demo2 table:

Output

After successfully implementing the above command, we will get the following result where we can see that both the values of Column A and Column B have been entered successfully.

PostgreSQL Text

Overview

In the PostgreSQL Text data type section, we have learned that the Text data type can be used for the unlimited length.


Next TopicPostgreSQL Varchar




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA