Let's say I create a table like this:
table = Table('mytable', metadata,
Column('a', Integer, primary_key=True),
Column('b', Integer, primary_key=True),
)
table.create()
Is it guaranteed that the primary key will be (a,b) and not (b,a)?
Let's say I create a table like this:
table = Table('mytable', metadata,
Column('a', Integer, primary_key=True),
Column('b', Integer, primary_key=True),
)
table.create()
Is it guaranteed that the primary key will be (a,b) and not (b,a)?
Yes. It will be a really bad thing if resulting DDL wasn't giving consistent results.
USe echo=True and compare yours with a swapped version? That should give the answer.
its guaranteed, yes, since Column
objects in Table
are ordered. or if you really want to be explicit, use PrimaryKeyContraint()
.