You insert NULL value by typing NULL:

INSERT INTO table(number1,number2,number3) VALUES (1,NULL,3);

If you have a variable and when that variable is empty you want to insert a NULL value you can use NULLIF with the variable enclosed in single quotes to prepare for that (this is somewhat dirty solution as you have to treat the variable as an empty string and then convert it to integer):

INSERT INTO table(number1,number2,number3) VALUES (1,NULLIF('$var','')::integer,3);
Answer from Simo Kivistö on Stack Overflow
🌐
PostgreSQL
postgresql.org › docs › 7.3 › sql-insert.html
PostgreSQL: Documentation: 7.3: INSERT
January 1, 2012 - INSERT INTO table [ ( column [, ...] ) ] { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) | SELECT query } ... The name (optionally schema-qualified) of an existing table.
🌐
Quora
quora.com › How-do-you-insert-a-null-value-in-PostgreSQL
How to insert a null value in PostgreSQL - Quora
Answer: Just not refering to the columns you expect having NULL value in the INSERT statement. On condition they don’t have a NOT NULL constraint. Let’s say you have the table dummy(id int, name varchar(20), location varchar(32)) then you can write: INSERT INTO dummy (id) VALUES (1), (2), ...
🌐
W3Docs
w3docs.com › php
postgresql insert null value on query
<?php $query = "INSERT INTO table_name (column_name) VALUES (NULL)"; $result = pg_query($connection, $query); ... Make sure the variable $connection is a valid connection to your postgresql db.
🌐
Data and Open Source
ftisiot.net › posts › postgresql-isnull
11 Lessons to learn when using NULLs in PostgreSQL® | Data and Open Source
For a weird reason, the design of this table will force us to join with users on the surname which is a NULLABLE field. CREATE TABLE sessions (id serial, surname text, session_time timestamp); INSERT INTO sessions (surname, session_time) values ('Doe', CURRENT_TIMESTAMP - INTERVAL '1 day'), ('Doe', CURRENT_TIMESTAMP - INTERVAL '1 day'*2), ('Spencer', CURRENT_TIMESTAMP - INTERVAL '1 day'*2), ('Spencer', CURRENT_TIMESTAMP), (NULL, CURRENT_TIMESTAMP), (NULL, CURRENT_TIMESTAMP - INTERVAL '1 day'*2), (NULL, CURRENT_TIMESTAMP - INTERVAL '1 day'*2), (NULL, CURRENT_TIMESTAMP - INTERVAL '1 day'*1), (NULL, CURRENT_TIMESTAMP);
🌐
PostgreSQL
postgresql.org › message-id › [email protected]
PostgreSQL: Re: Inserting NULL into Integer column
February 18, 2004 - Phew, now that that's out of the way, here's the standard ways of doing it. Use DEFAULT: If no default is it will insert a NULL, otherwise the default will be inserted: insert into table (integervar) values (DEFAULT);
🌐
Dirask
dirask.com › posts › PostgreSQL-Insert-NULL-values-jQq5Gj
PostgreSQL - Insert NULL values
INSERT INTO "users" ( "name", "surname", "department_id", "salary") VALUES (NULL, NULL, NULL, NULL), ('Simon', NULL, NULL, NULL), ('Taylor', 'Martin', NULL, NULL), ('Andrew', 'Thompson', 1, NULL), ('Taylor', 'Martin', 2, '2000');
Find elsewhere
🌐
GitHub
github.com › brianc › node-postgres › issues › 1649
Inserting null values to integer columns using a prepared statement · Issue #1649 · brianc/node-postgres
May 15, 2018 - Consider the following: let query = ` UPDATE inventory SET (item, price) = ($1, $2) `; await p.query(query, ["computer", ""]); The above query would result in the following error: UnhandledPromiseRejectionWarning: error: invalid input sy...
Published   May 15, 2018
🌐
TutorialsPoint
tutorialspoint.com › postgresql › postgresql_null_values.htm
PostgreSQL - NULL Values
It is very important to understand ... of using NULL while creating a table is as follows − · CREATE TABLE COMPANY( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL );...
🌐
PostgreSQL
postgresql.org › message-id › CAGgjfiTX+m1DKxSti7EQXdCgO-swqEF28kf=g6Jv9RK=KkWTqA@mail.gmail.com
PostgreSQL: Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns
November 22, 2011 - i.e.: insert into table1 (column1, column2) values (0, NULL); where column2 is of type integer with attributes NOT NULL DEFAULT 0
🌐
Experts Exchange
experts-exchange.com › questions › 21007602 › php-postgresql-inserting-null-values-for-timestamp-and-date-datatypes.html
Solved: php/postgresql inserting null values for timestamp and date datatypes | Experts Exchange
May 31, 2004 - if null is assigned to a date or timestamp field if (empty($DatPurch)) { $DatPurch='null';} then on the insert query the variable has to have no single quotes ie $DatPurch, or null value will cause an error.
🌐
Highgo Software Inc.
highgo.ca › home › 2020 › october › 20 › the way pg store null value in record
The way PG store null value in record - Highgo Software Inc.
August 3, 2023 - For example, for a table t (i int, j int, k int), we can execute insert into t values (8,1,6), or insert into t values (3, null, 7) to insert a record with a null value. This blog will explore some technical details of storing null values in ...
🌐
Rust Programming Language
users.rust-lang.org › help
How to insert a NULL value in SQL - help - The Rust Programming Language Forum
May 27, 2019 - Rust doesn't have NULL, but SQL does. In the postgres driver, what do I need to pass to insert a NULL value in the table? I've tried with &None and that's not it, and the documentation is silent on this question (it expl…
🌐
Restack
restack.io › p › understanding-tinyint-vs-int-in-sql-answer-insert-null-integer
Postgres Insert Null Into Integer | Restackio
Learn how to handle null values in integer columns with Postgres, focusing on the nuances of inserting nulls effectively. ... When working with integer columns in PostgreSQL, inserting NULL values is a straightforward process that can be crucial for maintaining data integrity.