Robert Walker <[email protected]> writes: > Jarl Friis wrote: >> Philip Hallstrom <[email protected]> writes: >> >>>> CREATE TABLE properties ( >>> >>> add_index :properties, [:namespace, :name], :unique => true >> >> After trying this and opening my interactive SQL prompt (psql), I can >> see that this only creates an index on the table not a table >> constraint. I can still put duplicate rows in the table. > > Excerpt from the PostgreSQL manual: > ---------------------------------- > PostgreSQL automatically creates a unique index when a unique constraint > or a primary key is defined for a table. The index covers the columns > that make up the primary key or unique columns (a multicolumn index, if > appropriate), and is the mechanism that enforces the constraint. > ----------------------------------
This says that an index is created whenever you create a constraint, not that a constraint is created whenever you create an index. Nevertheless, it seem to be a fact, that whenever you create an unique index, it also craetes a constraint. Jarl -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

