~/ learn/ postgresql/ cards/ Data types & constraints
1 of 2

Create a table ratings(book_id int NOT NULL, stars int NOT NULL CHECK (stars BETWEEN 1 AND 5)), insert (1, 5), and RETURN all columns.

Create a table ratings(book_id int NOT NULL, stars int NOT NULL CHECK (stars BETWEEN 1 AND 5)), insert (1, 5), and RETURN all columns.

Answer

CREATE TABLE ratings ( book_id int NOT NULL, stars int NOT NULL CHECK (stars BETWEEN 1 AND 5) ); INSERT INTO ratings VALUES (1, 5) RETURNING *;

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/7bc9938f-4c41-4a71-8b9f-bd20fbe13c43/flashcard utf-8 LF