Search code examples
sqlteradata-sql-assistant

Trying to do a INSERT INTO in SQL


So I have created the following table:

CREATE TABLE TABLE1
(
    CATEGORY varchar(255),
    CODE int
)

And I try to run the following code:

INSERT INTO TABLE1 ( CATEGORY, CODE )
VALUES ("xxxxx",1)

But I get the following error:

"Column xxxxx not found in TABLE1"

As far as I know, I am following the corect format. I am coding in Teradat SQL Assistant if that makes any difference


Solution

  • You probably need to use single quotes around string literals:

    INSERT INTO TABLE1 ( CATEGORY, CODE )
    VALUES
        ('xxxxx', 1);
    

    Based on the error message, Teradata seems to be interpreting the double quotes as a column name/alias.

    There is a Teradata community post about this:

    Single quotes are string delimiters. Double quotes are used for identifiers like column & table names. But in Teradata double quoted identifiers are not case sensitive (this is a deviation from Standard SQL)