Home > Back-end >  What does citext NULL mean in PostgresSQL
What does citext NULL mean in PostgresSQL

Time:05-07

What does this mean in PostgreSQL

columnName citext NULL

Im working on some SQL change, there is data in the database, but doesn't show in the front end. Wonderig if this NULL makes the values go into null state?

CodePudding user response:

The part you have shown means nothing and won't work as it is. This will likely be part of a table definition. If you need further details which differenes exist between CITEXT and TEXT or VARCHAR, you should have a look in the documentation: documentation

The "NULL" at the end just means that this column will be nullable. You can remove this if it confuses you. The opposite would be columnName citext NOT NULL. The entire create table command can look like this:

CREATE TABLE example 
(
columnName CITEXT NULL,
columnName2 CITEXT NOT NULL
);

When you want to insert or update rows of this table, only the first column can be null. The second column requires a not null value. As example, this insert will succeed:

INSERT INTO example VALUES (NULL,'1');

But this one will fail:

INSERT INTO example VALUES ('1',NULL);

CodePudding user response:

Postgresql citext

From documentation The citext module provides a case-insensitive character string type, citext. Essentially, it internally calls lower when comparing values. Otherwise, it behaves almost exactly like text.

[NULL after field type] (https://www.postgresql.org/docs/current/ddl-constraints.html) From documentation this simply selects the default behavior that the column might be null. The NULL constraint is not present in the SQL standard and should not be used in portable applications. (It was only added to PostgreSQL to be compatible with some other database systems.)

  • Related