To the best of
my knowledge, you would first
need to query to get the names of the tables and columns.
There isn't a standardized SQL way to do this,
but most RDBMS implementations do offer a way to do it. This is called
metadata or
schema querying. Sometimes the RDBMS provides helpers to do this, sometimes it exposes the schema as a table or view that can be queried. For example:
MySQL
SHOW TABLES;
SHOW COLUMNS IN Customers;
or
SELECT table_name FROM INFORMATION_SCHEMA.TABLES;
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'Customers';
T-SQL
SELECT * FROM information_schema.tables;
SELECT * FROM sysobjects WHERE xtype='U';
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'Customers';