INSERT

CREATE TABLE author
(
	author_id int GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1) NOT NULL,
	full_name varchar(128),
	rating decimal NOT NULL
);

INSERT INTO author (full_name, rating)
VALUES 
('Sem', 4.5),
('Bob', 4),
('Cat', 3.5),
('Tmp', 2);

SELECT * FROM author;

-- Create new table and copy specific values into it
SELECT *
INTO best_authors
FROM author
WHERE rating >= 4;

SELECT * FROM best_authors;

-- Copy multiple values from aone table to another 
INSERT INTO best_authors
SELECT *
FROM author
WHERE rating < 4.5;

Last updated

Was this helpful?