0

I have created a table and trying to perform a simple insert statement. I am getting an error saying ERROR: column "namespecies" of relation "species" does not exist.

Here is my table:

CREATE TABLE Species (
    nameSpecies             VARCHAR(50)     NOT NULL,
    scientificName          VARCHAR(50)     NOT NULL,
    population              BIGINT          NOT NULL,
    CONSTRAINT Species_cc0 PRIMARY KEY (nameSpecies),
    CONSTRAINT Species_cc1 UNIQUE (scientificName),
    CONSTRAINT Species_formatNom CHECK
        (nameSpecies SIMILAR TO '[a-z ]*' AND scientificName SIMILAR TO '[a-z ]*')
);

Here is my insert statement:

INSERT INTO Species (nameSpecies, scientificName, population) VALUES ('cat', 'feline', 600000000);

Am I missing something??

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
Sarah Lk
  • 11
  • 1
  • 3
  • Your code works: https://dbfiddle.uk/?rdbms=postgres_13&fiddle=23ef68259453c38bef306a98f5b0e054. – Gordon Linoff Feb 20 '21 at 03:47
  • Perhaps you did not use the exact statement that you show. Could it be, that you quoted the fieldnames in your create table statement? `“nameSpecies“` preserves capitalization `nameSpecies` will be lowercased. – clamp Feb 20 '21 at 07:35
  • My guess: https://stackoverflow.com/q/20878932/939860 – Erwin Brandstetter Feb 20 '21 at 08:48
  • Never Ever Use CamelCase In SQL. There Is No Need For And Will Only Generate Issues, No Matter What Brand Of DataBase You Use. – Frank Heikens Feb 20 '21 at 09:22

0 Answers0