尝试在 SQL 中执行 INSERT INTO

Trying to do a INSERT INTO in SQL

所以我创建了以下 table:

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

然后我尝试运行以下代码:

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

但是我收到以下错误:

"Column xxxxx not found in TABLE1"

据我所知,我遵循正确的格式。我正在使用 Teradat SQL Assistant 编写代码,如果这有什么不同的话

为什么不直接使用 SELECT 语句?

INSERT INTO TABLE1 ( CATEGORY, CODE )
     SELECT 'xxxxx', 1

您可能需要在字符串文字周围使用单引号:

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

根据错误消息,Teradata 似乎将双引号解释为列 name/alias。

关于这个有一个Teradata community post

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)

使用:

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