Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2013
    Posts
    13

    Unanswered: Create an ENUM column with pgAdmin

    I am working on a conversion project from MySql to PostgreSQL, so I am a newbie to PostgreSQL. I can't figure out how to change or add a column as an ENUM type. I have created the type and got it to display in pgAdmin.
    All examples out there show a sql command to create the column, but none using pgAdmin or Navicat.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by GaryK4 View Post
    All examples out there show a sql command to create the column, but none using pgAdmin or Navicat.
    Because you shouldn't modify your database structure like that.

    You should do all modifications to the data model through SQL scripts that are stored in a version control system. "ad-hoc" changes to the data model will quickly lead to chaos (and questions in this forum on how to compare a dev-DB against a production DB because you completely lost track which change has been applied where).

    And besides: enums are usually a sign of design that can be improved. Most of the time it's better to either store a proper foreign key to a lookup table or simply apply a check constraint to limit the values. Both solutions are much more flexible than enums.

    Having said all that:

    To add a column, right click on the table, select "Properties", switch to the "Columns" tab, click the "Add" button, enter the column name and select the enum type from the dropdown.

    http://i59.tinypic.com/2zoyfyx.png
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •