Solved

Is there a way to make a column primary key when the table/view is already created?

  • 27 March 2024
  • 1 reply
  • 25 views

Badge

Is there a way to make a column “primary key” even when the table already existed with no primary keys at all? 

There are things you have to consider, right? 

  • All the already existing data needs to be formatted to this new primary key, so it can’t be null
    • So how do you alter this data? Do you have to manually do this in data conversion or SSMS?
icon

Best answer by Mark Jongeling 27 March 2024, 14:15

View original

1 reply

Userlevel 7
Badge +23

Hi Alieev,

Certainly! Simply check the Primary key checkbox at all fields that should be in the Primary key in the Software Factory, Datamodel > Tables > Columns. More info here: Data model | Thinkwise Documentation (thinkwisesoftware.com)

The Software Factory will upgrade the table for you when you start and finish a whole Creation cycle (Generate definition, Validate definition, Generate source code (Smart or Full, both work), and lastly Execute source code). 

If data needs to be migrated, you can use Data migration to determine how old fields should be mapped to new fields. More info here: Data migration | Thinkwise Documentation (thinkwisesoftware.com)

In more complex scenarios, you can even opt to use an Upgrade control procedure. More info on that here: Functionality | Thinkwise Documentation (thinkwisesoftware.com)

Reply