Adding sequences in phpPgAdmin

Armijn Hemel, November 15, 2010, 14972 views.

PostgreSQL is a very powerful database engine. A helpful tool for managing PostgreSQL databases is phpPgAdmin. Although it is a good tool some things are a bit quirky.

Tags: ,

One of the differences between MySQL and PostgreSQL is how autoincrements work. In MySQL you use the AUTOINCREMENT keywords, in PostgreSQL you use a sequence.

In phpPgAdmin a sequence is created as follows:

  • open the database
  • find the right schema you want to add the sequence to (for example public)
  • click on the option 'sequences'
  • add a sequence

That is the easy part. Adding it to the correct column so I could use it is a bit different. In the interface for phpPgAdmin I searched for a long time for the right option how to use the sequence, but could not find it. The good news is that it is not very difficult at all to use it, you just need to know that you cannot do it in the interface.

For me the solution was simple: use it in the default section for a column, for example:

nextval('id_sequence')

for an integer value.

Social networking: Tweet this article on Twitter Pass on this article on LinkedIn Bookmark this article on Google Bookmark this article on Yahoo! Bookmark this article on Technorati Bookmark this article on Delicious Share this article on Facebook Digg this article on Digg Submit this article to Reddit Thumb this article up at StumbleUpon Submit this article to Furl

Talkback

respond to this article