SELECT * FROM TABLES;

SELECT * FROM TABLES WHERE table_schema='ilp540' LIMIT 10;

SELECT * FROM COLUMNS WHERE table_schema='ilp540' LIMIT 10;

SELECT t.TABLE_NAME,
       COUNT(c.COLUMN_NAME) AS FIELDS, 
       SUM(CASE WHEN C.COLUMN_KEY='MUL' THEN 1 ELSE 0 END) AS FKs,
		 SUM(CASE WHEN C.COLUMN_KEY='PRI' THEN 1 ELSE 0 END) AS PKs
		 INTO OUTFILE 'c:/tmp/exportdata/tabelas.txt' FIELDS TERMINATED BY ','
       FROM TABLES AS t INNER JOIN COLUMNS AS c ON t.table_name=c.TABLE_NAME
	    WHERE t.table_schema='ilp540' GROUP BY t.table_name
                                      ORDER BY t.table_name, ordinal_position; -- LIMIT 15
SELECT * INTO OUTFILE 'c:/tmp/exportdata/tabelas.txt'
  FIELDS TERMINATED BY ',' FROM TABLES ;
