IBM Support

Error "201: A syntax error has occurred." when creating a table

Troubleshooting


Problem

You get error "201: A syntax error has occurred." when trying to create a table.

Symptom


create table t1 (
   c1 int,
   primary int);

  201: A syntax error has occurred.
Error in line 1
Near character position 34

Cause


This could be because you are using the following reserved words as a column name:

  • CHECK
  • DISTINCT
  • FOREIGN
  • PRIMARY
  • UNIQUE

Resolving The Problem


Although you can use these reserved words as an identifier, syntactic ambiguities can result from using keywords as identifiers in SQL statements. The statement might fail or might not produce the expected results. However, if you must use these reserved words as column names, you can use the following workaround:


Create the table without the column that has the keyword name, then ALTER TABLE to ADD the column with the reserved word. For example:

create table t1 (c1 int);
ALTER TABLE t1 ADD primary int;

Related Information

[{"Product":{"code":"SSGU8G","label":"Informix Servers"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF022","label":"OS X"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"10.0;11.1;11.5;11.7","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
16 June 2018

UID

swg21441150