2

In Sqlite, I can query for tables names and their structure like this:

SELECT name, sql 
FROM sqlite_master 
WHERE type = 'table' AND Name NOT LIKE '%sqlite%'  

I want to query for database schematic for MySQL database. Some digging in phpMyAdmin, I end with this:

SELECT SCHEMA_NAME, TABLE_NAME 
FROM SCHEMATA, TABLES 
WHERE SCHEMA_NAME = TABLE_SCHEMA AND SCHEMA_NAME ='myDb'

Unfortunately, this will only output tables names. Is there any sql query do the some work of:

mysqldump -u root myDb --no-data=true --add-drop-table=false > myDb.sql 
mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
SIFE
  • 5,567
  • 7
  • 32
  • 46

2 Answers2

2
select * 
from information_schema.columns
where table_schema = 'sqlite_master'
order by table_name, ordinal_position

based on the accepted answer from this SO question

Community
  • 1
  • 1
Matt Busche
  • 14,216
  • 5
  • 36
  • 61
  • Note that the `INFORMATION_SCHEMA` tables/views are a part of the ISO SQL92 standard. They should be present on all modern RDBMSs. Unfortunately, SQLite currently does not implement these standard metadata tables/views. – Bacon Bits Feb 15 '13 at 21:45
1

How about

SHOW CREATE TABLE tablename;
Richard O
  • 11
  • 2