Get Firefox! "my blog doesn't just deal with my life, it deals with some important stuff too"

27th of March 2005

Google

I was trying to work out how to create a Joint Primary Key in Postgres earlier as I found a bug in my major project due to an error with the primary key. I tried googling, originally, for postgres "joint primary key" which gave very few (and not at all helpful) results. So I generalised the search to "joint primary key". I found what I needed, and implemented it ... another job well done.

After I had finished I closed down the editor. Behind it was the Google search results window. As I was about to close it I noticed a very familiar title in the search results: "LoweyBlog 2" ... Seems my blog is on the first page of results for the search term "joint primary key". I was the seventh result at the time of writing! :-s

Anyway, I am aware that there is now a possibility that this entry may end up on the google results page for searches about how to create a primary key in SQL, so here is how I did it, for anyone who came here wanting to know how it's done:

ALTER TABLE ONLY table_name ADD CONSTRAINT table_name_pkey PRIMARY KEY (column1, column2);

HTH. --Lowey

Blog #470, posted at 07:26 (GMT)