Open In App
Related Articles

PostgreSQL – TEXT Data Type

Improve Article
Improve
Save Article
Save
Like Article
Like

PostgreSQL supports a character data type called TEXT. This data type is used to store character of unlimited length. It is represented as text in PostgreSQL. The performance of the varchar (without n) and text are the same.

Syntax: variable_name TEXT

Example 1:
Let’s create a new table(say, text_test) for the demonstration using the below commands:

CREATE TABLE text_test (
    id serial PRIMARY KEY,
    x TEXT,
        y TEXT
);

Now let’s insert a new row into the char_test table using the below command:

INSERT INTO text_test (x, y)
VALUES
    (
        'Geeks',
        'This is a test for char'
        
    );

Now that we have managed to successfully assign the values to the character data type, check it by running the below command:

SELECT * FROM text_test;

Output:

Example 2:
Let’s create a new table(say, text_test2) for the demonstration using the below commands:

CREATE TABLE text_test2 (
    id serial PRIMARY KEY,
    a TEXT,
        b TEXT
);

Now let’s insert a new row into the char_test table using the below command:

INSERT INTO text_test2 (a, b)
VALUES
    (
        'GeeksForGeeks',
        'GeeksForGeeks is the Best.'
        
    );

Now that we have managed to successfully assign the values to the character data type, check it by running the below command:

SELECT * FROM text_test2;

Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Aug, 2020
Like Article
Save Article
Previous
Next
Similar Reads