© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
3 replies
lewisd

How do I create a composite key?

I know how to do this in the UI, but how can I do this in SQL?

create table "userWantList" (
  userId uuid references "userData" (id) primary key,
  "createdAt" timestamp default now(),
  "collectibleId" character not null primary key,
  "collectibleType" bigint references "collectibleTypes" (id)
);
create table "userWantList" (
  userId uuid references "userData" (id) primary key,
  "createdAt" timestamp default now(),
  "collectibleId" character not null primary key,
  "collectibleType" bigint references "collectibleTypes" (id)
);


Gives me the error
multiple primary keys for table "userWantList" are not allowed
multiple primary keys for table "userWantList" are not allowed
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Composite key foreign key issue
SupabaseSSupabase / help-and-questions
6mo ago
Composite Primary Key creation error
SupabaseSSupabase / help-and-questions
4y ago
Make composite primary key unique
SupabaseSSupabase / help-and-questions
4y ago
How to use composite key as foreign key in another table?
SupabaseSSupabase / help-and-questions
4y ago