Adding a Primary Key to a database table

I am trying to add an id column to my database table. The instructuional videos did not mention how to assign a primary key in a named query. Everything i try gives me a syntax error. Can someone please share what the named query is supposed to look like for a primary key. Thanks

You don't define primary keys in named queries. That is "DDL", data definition in your DB, not "DML", data management, which is what SELECT and UPDATE queries do.

If you are trying to provide a specific value for a primary key column, you'd do that just like any other value.

1 Like

I am trying to define one of the columns as the primary key column the same way the "Tank" table from the example project has "TankNo" as the key. If its not done in the Named Queries where do I establish it?

In whatever database management UI you normally use to create tables. If you know the SQL syntax, you can use the designer's Query browser, but it isn't very friendly.

(This stuff is somewhat DB brand-specific.)

I use JetBrains DataGrip, fwiw. (Multiplatform.)

1 Like

Don't take this the wrong way, but you should probably learn database basics before trying to use them in ignition. It will save you a lot of headache.