Jump to content

Recommended Posts

I have a few questions:

1. Can you search a whole DB for tables that contain a certain field? For example Search DB1 for any table that contains the field username?

 

2. How can I go about changing the prefix on every table name without indivudually doing it? ie. ex_table1, ex_table2, ex_table3, ex_table4 and change this to ie_table1, ie_table2, ie_table3, ie_table4

 

I appreciate the help!

Link to comment
https://forums.phpfreaks.com/topic/272964-couple-search-questions-in-mysql/
Share on other sites

1. information_schema contains a number of tables which you may find useful, such as TABLES.

 

2. Easiest way would be to use SQL to construct a series of RENAME TABLE statements (also using information_schema). Then run those statements. I mean like

SELECT CONCAT("RENAME TABLE `", t.TABLE_SCHEMA, "`.`", t.TABLE_NAME, "` TO `", new name for the table, "`;") FROM information_schema.TABLES...

Or perhaps easier would be to make a PHP script to pull the table names and execute a RENAME TABLE for each.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.