PRIMARY KEY: App connected to MySQL DB > with MY_ID field set as Autoincrement

The app is connected to a MySQL database. AppSheet doesn’t have auto-increment (and I am not interested in a random UNIQUEID()).

I created a database column called MY_ID as primary key set as unique, and auto increment. Every time the user adds a new row, the database will increment the MY_ID column automatically. This provides me with the autoincrement.

Within the app, I cannot use MY_ID as the key, because it will mark it as required. It cannot be set as required, it has to be empty, because the database will provide a new MY_ID for every new record.

I tried using the _RowNumber as key, but it trows this error:
image

Should the _RowNumber be created within MySQL? I am not able to add new records.

Any suggestions on how to set the app table key? And keep the DB to generate an autoincrement field?

The app must assign the row’s key column value. There is no way to avoid that. A server-generated value cannot be used as the row’s key within the app. The best you can hope to accomplish is to have two separate and independent values: the key the app uses in one column, and a key the database uses in another column. They cannot be the same.

1 Like