0

I've seen this error mentioned on StackOverflow, but not in the context I am using. I am relatively new to Teradata and this behavior is throwing me for a loop. Here is code that works:

INSERT INTO test_table (this, that) VALUES (1, 2);

Here is code that throws the error:

INSERT INTO test_table (this, that) VALUES (1, 2), (3, 4);

This is super confusing to me because the Teradata docs have the following example:

INSERT INTO cities VALUES (2, 'San Jose'), (3, 'Oakland');

Could someone show me what am I missing here? Thanks!

Aaron K.
  • 3
  • 2
  • 2
    Have you tried : `INSERT INTO test_table VALUES (1, 2), (3, 4);` just guessing...Do not know teradata – VBoka Jan 24 '20 at 22:59
  • Yeah, I’ve tried moving spaces around. Same behavior :/ – Aaron K. Jan 24 '20 at 23:01
  • Sorry, spaces ? I have removed column names from the statement... Also please can you give us the link you are talking about: "Teradata docs have the following example" if it is online.... :) – VBoka Jan 24 '20 at 23:03
  • This is the source ? https://teradata.github.io/presto/docs/0.167-t/sql/insert.html – VBoka Jan 24 '20 at 23:08
  • Are you using the github project or are you using the product sold by teradata.com? Your statement is indeed documented at the former but I don't think it's supported by the latter. At least that's what I find at docs.teradata.com? – Jeff Holt Jan 24 '20 at 23:10
  • Whoops! Sorry was walking and replying, disregard. Yes, I have tried w/o column specifications to the same avail. Here is the [knowledge base article.](https://teradata.github.io/presto/docs/0.167-t/sql/insert.html) -- actually on further investigation, I'm not sure what 'presto' is and whether or not my company is using it. This might impact the behavior... – Aaron K. Jan 24 '20 at 23:13
  • Teradata doesn 't support multi-row inserts (the docs are not for Teradata SQL). You must use `INSERT INTO cities VALUES (2, 'San Jose');INSERT INTO cities VALUES (3, 'Oakland');` At least you can submit it using a *Multi Statement Request* (F9 instead of F5) – dnoeth Jan 24 '20 at 23:13

1 Answers1

0

Teradata only allows you to insert one record with a single values. You can see this in the syntax diagram for insert -- there is no "backloop".

Two inserts is a simple workaround:

INSERT INTO test_table (this, that)
    VALUES (1, 2);
INSERT INTO test_table (this, that)
    VALUES  (3, 4);
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786