Jump to content

Couple Search questions in MySQL


jbradley04

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.