WordPress.org

Ready to get started?Download WordPress

Forums

I need to change the options table name (6 posts)

  1. tomchadenga
    Member
    Posted 2 years ago #

    I want to change the options table name (please NOT the prefix) the actual name from 'options' to 'myoptions' say for example. HOW is this done? If i am to use the prefix route then i would need to have a different prefix for the options table compared to the other tables. Reason for doing this is that I want to have more than one options table in the db, so that i can have more than one installation reading and editing the same tables in the same database, but from more than one website.

    Dont give me plugins. I want to know how the table names can be different. Why does WP keep their tables so rigid? That SUCKS! Let me be able to mess around with the DB if i want to, for heavens sake! I have to come to a forum to get help for something that shuld be so straight forward!!!!!! ARRRRGGGGGG!!!!

  2. Eddie Moya
    Member
    Posted 2 years ago #

    If you need to create an additional custom table, you can certainly just do that. This page, intended for plugin developers, will show you how to create custom tables in WP.

    However, you really shouldn't need to do this for multiple sites. Are you already taking advantage of multisite?

    --Multisite
    If you just need multiple blogs/sites to work together, use multisite: http://codex.wordpress.org/Create_A_Network

    Multisite will do all the dirty business for you - no reason to go rummaging around the database trying to reinvent the wheel.

    --Separate instances
    If you are already have multisite, and are actually need multiple multisites, or if multisite for whatever reason doesn't seem to fit your needs (can't imagine why), and you absolutely need multiple instances of WordPress, you probably really should to have multiple databases.

    --Prefixes ARE the answer, weather you like it or not.
    That said.. there is a way to have multiple instances on a single database. I'm sorry if you dont like the answer, but it absolutely has to do with the table prefix.

    http://codex.wordpress.org/Installing_Multiple_Blogs

    I have not done this but I presume if you just install them separately as you normally would, and then just point both of them to the same database, you could just provide each install with a different prefix - can't see why such a thing wouldn't work (its essentially what multisite does)

    FYI: The reason its not simple to modify the schema is because your really just not supposed to. Developers in general should try to limit their direct handling of the database, because it can change over time from version to version while keeping the API more consistent. Not only that but plugins and WordPress itself expects the options table to be named a certain way, and changing it would break WordPress let alone plugins. Any new custom options table you might create would be invisible to WordPress, and not integrated into its API.

  3. tomchadenga
    Member
    Posted 2 years ago #

    Thanks, but if I were to do it, how would I successfully change the name of the options table? I tried changing the name in the 'tables' array in wp-db.php in the wp-includes folder from 'options' to something else but the gave me a whole lot of SQL errors for failed inserts and selects etc. I believe this means that I have not changed the reference to options in other pplaces in the wp files. How can i get it to install with a unique options table name? I dont want to believe that it is impossible. How can i get a unique options table name?

  4. Eddie Moya
    Member
    Posted 2 years ago #

    Thanks, but if I were to do it, how would I successfully change the name of the options table?

    You wouldn't. You can change the name of the options table, but wordpress will keep looking for table under the right name. There is no reason to ever do this, so there is no way to do this.

    I suppose if you want the ultimate answer.. you would need to change every instance where WordPress interacts with the options table in a sql query, and then do the same for any plugins that might directly play with the options table. Any time you your version of wordpress, you will need to do it all over again - or if possible merge the new version into your older custom version through whatever version control you like.

    Again,.. there is NO good reason whatsoever to do this, and its a really BAD idea. It accomplishes absolutely nothing.

  5. lloop
    Member
    Posted 2 years ago #

    Posting this late but .... for the benefit of others searching around for info on this subject ... mylagoons post writes about changing the prefix in the wp-settings.php file.
    Unfortunately it's outdated.
    I can think of several scenarios why someone would want to use the same database for multiple installs. Mine at the moment is because I want to locally run Stable, Trunk, and Beta installs and not have to duplicate database content. Of course I welcome good explanations as to why I shouldn't do this. But if it's just going to be "thats not what we do" ... please save the words.

  6. Eddie Moya
    Member
    Posted 2 years ago #

    I still see no reason to need to rename the actual tables, whatever distinction you need between sites can be accomplished with the table prefix. There is no reason what so ever to need to change the table name completely. Above you said an example name of 'myoptions', you can easily have that by setting the prefix to 'my'.

    I agree that there are many reason to have multiple sites on the same database (not the same set of tables, but different sets of tables on the same database) - but customizing the name of the options table outside of settings the prefix gets you no closer to that goal than just changing the prefix does.

    Now that I understand your goal a little better, I would suggest looking into HyperDB. I've not used it myself, and its not really intended for your purpose, but you could leverage its data partitioning capability to have two installations of wordpress and mix-match the tables one of them points to. So that Instal#2 points to all the same tables as Install#1, except for the options table, which would remain separate.

    Make sense?

Topic Closed

This topic has been closed to new replies.

About this Topic