I have a table with about 20 columns. 10 of them generally tend to have 1 of 15 or so possible values (different for each column). In addition, one column has a largish string. The table currently has over 3 million rows, and growing. It is about 1GB big (just data)
- I would like to split off the large text column, since it is not used often and would probably dramatically reduce the table size, thus improving performance.
- I would like to "normalize" all those repeating columns into a separate table (each), so that I can get the list of current values without running 10
distinctqueries on 3M rows. It takes a long time.
#2 would be one-to-many relations. #1 could be 1-to-1 or 1-to-many. I don't care.
The question is: Can these be done by pure SQL statements? How? Or do I need to write a program to put the data in the new table and get the PK and insert it in the right column, one row at a time?
Edit
Here is a sample of what I am trying to do:
ID Field1 Lookup Text
10 val1 look1 some very long text
11 val2 look2 more very long text
12 val2 look1 NULL
13 val4 look1 some very long text
.
.
.
To this:
ID Field1 Lookup Text
10 val1 1 1
11 val2 2 2
12 val2 1 0
13 val4 1 4 (1?)
.
.
.