I have a table which contains many fields. I'd like to set "id" and "userId" as a composite primary key in HeidiSQL, do you know if it is possible with this software?
In HeidiSQL, you would normally just click the relevant table to get into the table editor. Then, select the both column names, right click, point to Create new index, then click on Primary. You will see the new key appearing in the upper Indexes tab, where you can add more fields, remove it again and whatever.
Here are the steps to create composite primary key in MySQL. You can create composite primary key, either during table creation using CREATE TABLE statement, or after creating tables using ALTER TABLE statement. We will look at both these examples to create composite primary key in MySQL.
In this tutorial I'd like to show you how to view table foreign keys with HeidiSQL. To see table FKs first select table in the object explorer, then select Table tab, and under this tab select Foreign keys tab. All table foreign keys will be visible in the list on the upper part of the window.
A composite key is a key that is the combination of more than one attribute or column of a given table. It may be a candidate key or a primary key. Attention reader!
In HeidiSQL, you would normally just click the relevant table to get into the table editor. Then, select the both column names, right click, point to Create new index
, then click on Primary
. You will see the new key appearing in the upper Indexes
tab, where you can add more fields, remove it again and whatever.
using a command like this will work in most databases
alter table myTable add constraint pkc_Id_UserID primary key (id, userid)
click please on the your id and select Add to index
after that select primary key
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With