Showing entries 1 to 1
Displaying posts with tag: sql from sql (reset)
SQL from SQL

This is a simple technique, to write a report that generates SQL syntax, that you can then turn around and execute. I've heard this called "SQL from SQL" or sometimes "dynamic SQL"--although it doesn't use prepared statements or anything like that.

There are a few simple options in SQL*Plus (Oracle's command-line tool) to accomplish this, and a few simple--but different--options in mysql (MySQL's command-line tool).

Try this line:

shell> mysql --silent --skip-column-names -e "select concat('describe ', table_name, ';') from information_schema.tables where table_schema = 'world'"

(Note I'm supplying my username and password to the session from an option file.) This sends the following to standard output:

describe City;
describe Country;
describe CountryLanguage;

The trick is to select the data you want from your system, combined with the …

[Read more]
Showing entries 1 to 1