Jojo
Jojo

Reputation: 51

Generic auto-increment foreign key

I'm writing sql scripts which I would like to run across platforms (mostly mysql and postgres). The problem I see is I cannot arrive at a common one for auto-increment primary keys which are used as foreign keys. Is there a way to do this ?

table t1 ( column c1 )
table t2 ( column c2 )

c1 is auto increment and c2 is a foreign key referenced on c1.

I tried keeping c1 as SERIAL and c2 as bigint/bigint unsigned/numeric , but no luck.

Upvotes: 0

Views: 98

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269683

Really, it is futile to try to get SQL code to work across multiple database platforms. There are just too many variations on the language.

In fact, the syntax for a stored procedure differs significantly between the two. So, you are going to have to write separate scripts for each database you want to support.

Upvotes: 2

Related Questions