3

I'm familiar with the syntax of create unique index 'blah' on 'some_table' ('col1','col2') however I'm unsure exactly how this will behave. More specifically, the documentation says

A column list of the form (col1,col2,...) creates a multiple-column index. Index values are formed by concatenating the values of the given columns.

That seems like it might be okay in some cases, but I want make a table that holds just numbers unique. So, I could see col1 being 12 and col2 being 2, which will concatenate to 122 from what I can tell, and then a value of col1 1 and col2 22 would match that, which is not what I want. Is there a way to define a separator for the concatenation or is there already one in place? Should I be doing this differently?

Here's an attempt at a diagram

table 1             middle               table 2
-------             ------               -------
t1_id               mid_id               t2_id
some_value          t1_id                another_value
                    t2_id

I want the t1_id and t2_id combination to be unique, but t1 can repeat and t2 can repeat.

2
  • Have you looked at INFORMATION_SCHEMA to see what your index looks like? Commented Feb 21, 2011 at 18:46
  • I haven't actually implemented the above design because I'm not sure that it would work. I could give it a try real quick. Commented Feb 21, 2011 at 18:49

1 Answer 1

3

It is not possible nor necessary to specify a separator. The index works as you want it to.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.