Basic INSERT

suggest change

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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents