postgresql INSERT Basic INSERT

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Let's say we have a simple table called person:

CREATE TABLE person (
    person_id BIGINT,
    name VARCHAR(255).
    age INT,
    city VARCHAR(255)
);

The most basic insert involves inserting all values in the table:

INSERT INTO person VALUES (1, 'john doe', 25, 'new york');

If you want to insert only specific columns, you need to explicitly indicate which columns:

INSERT INTO person (name, age) VALUES ('john doe', 25);

Note that if any constraints exist on the table , such as NOT NULL, you will be required to include those columns in either case.



Got any postgresql Question?