How to add a (primary) key to an existing table using SAP HANA

What is SQL command to add (primary) key to table in SAP HANA?

ALTER TABLE SAP library doc is cryptic to me

+3


source to share


3 answers


ALTER TABLE schema.table ADD PRIMARY KEY (column1,column2)

      



+6


source


To create a primary key on an existing table, use the following syntax in the SQL console:

alter table "schemaName"."tableName" add constraint primary_key_alias Primary KEY("Column_Name");

      



Where primary_key_alias is the name of the primary key. For more information: SAP Help

0


source


To add constraints to a column:

alter table "Schema_Name"."Table_Name"  add primary key ("Column_Name");

      

0


source







All Articles