If a foreign key constraint or primary key constraint spans only one column, you have the choice to write it your own way or like this:
CREATE TABLE test( id integer NOT NULL CHECK (id3>=id2), id2 integer, id3 integer, CONSTRAINT PK_test PRIMARY KEY(id, id2, id3) );
But if PK or FK spans more than one column, you should use a “table constraint”, as I showed you.
There is no more magic behind it!
source share