Forum: Ruby Database re-structuring

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dick D. (Guest)
on 2006-04-19 23:21
Hi everyone, I am looking for some suggestions here.

I've got an older mysql database, one table, dumped into a SQL file.

I want to use this data in my new database, only this time I want the
data to go into multiple tables instead of one big table.

I was thinking of writing a script to parse the SQL file and based on
each entry, put the information where it needs to go.  I also thought of
feeding the SQL file into my new database, and write a script that went
thought each row in the data of old table (with a SELECT *) and figured
out where to put it in the new tables.

Is this an insane way to do things?  I have a feeling I am doing a lot
more work than necessary.  Does anyone have any suggestions?
Ryan L. (Guest)
on 2006-04-20 00:17
(Received via mailing list)
On 4/19/06, Dick D. <removed_email_address@domain.invalid> wrote:
>
> Is this an insane way to do things?  I have a feeling I am doing a lot
> more work than necessary.  Does anyone have any suggestions?

If the dumped SQL is fairly simple and regular, I'd just write a
script to parse it and add things to the right tables. I think it is
overkill to import it into a new table just so you can later select
and re-insert it.

Ryan
zdennis (Guest)
on 2006-04-20 07:20
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ryan L. wrote:
>
Depending on how big the table was, you could do this all from within a
mysql batch script, by using "insert ... select" statements.

Zach
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFERv3pMyx0fW1d8G0RAmNbAJwOaBKouHWL0xDJh5WjmG0uKnj1IgCfb+RM
B5NCP6dClBplgDzh+LIQhW4=
=L1Pr
-----END PGP SIGNATURE-----
zdennis (Guest)
on 2006-04-20 07:26
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

zdennis wrote:
>>>script to parse it and add things to the right tables. I think it is
>>>overkill to import it into a new table just so you can later select
>>>and re-insert it.
>>>
>
>
> Depending on how big the table was, you could do this all from within a
> mysql batch script, by using "insert ... select" statements.
>

Actually it has nothing to do with big... it just has to do with writing
a mysql batch script...

Zach
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFERv7KMyx0fW1d8G0RAuihAJ9BZQ+thrHF7ePEOboIrxiJum9mxgCfZPAP
QJ/10EUzkWvbmI676bp7IUI=
=ETBE
-----END PGP SIGNATURE-----
Robert K. (Guest)
on 2006-04-20 13:25
(Received via mailing list)
2006/4/19, Dick D. <removed_email_address@domain.invalid>:
> Hi everyone, I am looking for some suggestions here.
>
> I've got an older mysql database, one table, dumped into a SQL file.
>
> I want to use this data in my new database, only this time I want the
> data to go into multiple tables instead of one big table.

> Is this an insane way to do things?  I have a feeling I am doing a lot
> more work than necessary.  Does anyone have any suggestions?

Since mysql 5 you can also write a stored procedure that will read the
table with a cursor and distribute the data to several tables.
Disclaimer: haven't used mysql stored procedures yet so I don't know
how mature they are.

Kind regards

robert
Dick D. (Guest)
on 2006-04-26 02:39
Robert K. wrote:
>
> Since mysql 5 you can also write a stored procedure that will read the
> table with a cursor and distribute the data to several tables.
> Disclaimer: haven't used mysql stored procedures yet so I don't know
> how mature they are.
>
> Kind regards
>
> robert

Thanks for the suggestion Robert (and everyone else).  I will have a
look at these "stored procedures" on mysql.org
This topic is locked and can not be replied to.