I have a database with the table superhero that is created like this:
CREATE TABLE Superhero
(
superhero_id serial PRIMARY KEY,
superhero_name varchar(50) NOT NULL,
superhero_alias varchar(50) NOT NULL,
superhero_origin varchar(50) NOT NULL
);
If I try to insert data using a INSERT INTO
statement, the environment says the data was successfully inserted, but the SELECT
statement has an 'index out of range' error.
Here is the insert code:
INSERT INTO superhero (superhero_name, superhero_alias, superhero_origin)
VALUES ('Mage', 'dummyMage', 'test1'),
('Rogue', 'dummyRogue', 'test2'),
('Ranger', 'dummyRanger', 'test2');
And here is the select code:
SELECT *
FROM public.superhero
ORDER BY superhero_id ASC
I also tried just inserting one item instead of three, and it didn't work.
And I tried to insert with a defined id, but it didn't work either:
INSERT INTO superhero
VALUES (0, 'Mage', 'dummyMage', 'test1' );
As Somendra Kanaujia suggested, the error was that I used the public.superhero
in the SELECT
statement, but nowhere else.