0

I want to add an extra table on my WordPress database and I intend to query it with a custom script that will be embedded to WordPress.

I'm worrying if this is a safe way to do it, or I should go with the option of adding an entirely new database, not a table on WordPress, as future updates of WordPress system might wipe my custom table? Any experience with such a scenario. Is this a valid risk/worry, or I should just create the table on the WordPress database, instead of creating another db, and connect to that new db in my custom script.

Thank you.

2
  • 1
    To answer your question, yes you can add a table without worry. To me the basic question is: Do I really need the extra table? Can I do it (what I am trying to do) using only WordPress API?
    – Laxmana
    Apr 18, 2017 at 15:09
  • Since this has been viewed 2K times I thought this answer might help some other people. Yes, it is safe and people do it all the time. Here is a good resource for how: codex.wordpress.org/Creating_Tables_with_Plugins Feb 23, 2022 at 19:17

1 Answer 1

1

There is no risk in creating new table in WP Database. Infact many well known and giant plugins, like Woocomerce do this.

You can also opt for creating new database but creating new table is not at all risky...

Hope I am clear enough...

3
  • Hello, Yes I have noticed that, however I wanted to make sure as I'm new to the world of wp and I just don't want to regret making any decision that might result dumb in the future. Thank you
    – Ryan
    Apr 18, 2017 at 14:54
  • 2
    Yes, creating new tables is quite common, when warranted. WP will not remove custom tables when it updates - it only affects tables it knows about. If you are just trying to add extra data to posts/pages/custom post types, you should probably use postmeta instead, as you don't need to mess with anything more custom like a separate table. But if you're adding data that's not related to anything else in the WP database, custom table is the right way to go. This should be the accepted answer. :)
    – WebElaine
    Apr 18, 2017 at 15:11
  • You are right, I totally agree with what you said, as this is precisely what I was thinking
    – Ryan
    Apr 18, 2017 at 15:22

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.