简体   繁体   中英

ALTER TABLE Statement -> sql syntax error: incorrect syntax near """: line 1 col 49 (at pos 49)'

I write a python program, where I generate a SQL-Table. Also I want to add Column to this Table, but then I become the error idh_jdbc java.lang.Exception: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near """

My Code:

alter = f'ALTER TABLE "CELONIS_E2E"."CAG_List" ADD COLUMN "{header[x]}" {sqltype}'

sqltype = NVARCHAR(255)

header[x] = Assigned_Groups_2

The Print-out: ALTER TABLE "CELONIS_E2E"."CAG_List" ADD COLUMN "Assigned_Groups_2" NVARCHAR(255)


According to the SAP Hana specifications, you should not include "COLUMN".

The SQL should be

ALTER TABLE "CELONIS_E2E"."CAG_List" ADD "Assigned_Groups_2" NVARCHAR(255)

based on the specification for the add columns clause below:

<add_columns_clause> ::= ADD ( <column_list > )

<column_list> ::= <column_specification> [, <column_specification> [,...] ] [ ONLINE [ PREFERRED ] ]

<column_specification> ::=  
 <column_name> { [ <column_definition> ] [ <column_constraint_short> ] [ COMMENT <string_literal> ] }
     CLIENTSIDE ENCRYPTION ON WITH <column_encryption_key_name> [ RANDOM | DETERMINISTIC ] [ <column_load_unit> ]

<column_load_unit> ::= <column_name> <load_unit>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM