0

I have a sql file I will use for adding new records into a database. it involves much re-formatting data as the target is normalised to a far greater extent than the source. can I declare table names initially like

srcdb = 'dump_130113';
targetdb = 'test';

then refer to them like

select * from srcdb.tablename;

I know about

use database_name;

the problem is even doing that will require switching back and forth many times.

4
  • Can you wrap what you're doing in a scripting language like PHP or Perl? They can substitute into the SQL commands. Commented Jan 13, 2013 at 3:25
  • 1
    Check this SO question. Commented Jan 13, 2013 at 4:03
  • Looks like too much effort tbh, thanks anyway :) Commented Jan 13, 2013 at 4:23
  • Have you seen the answer provided at stackoverflow.com/questions/700970/variable-database-name Commented Jun 27, 2013 at 15:16

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.