I need to export a mysql table, but it has like 5gb of entries, so I only want the structure. I am trying to do it from a simple php doing a sql query, how can I do that?
Asked
Active
Viewed 9.3k times
4 Answers
126
You can use SHOW CREATE TABLE
for this.
Shows the CREATE TABLE statement that creates the given table. The statement requires the SELECT privilege for the table. As of MySQL 5.0.1, this statement also works with views.
E.g.:
SHOW CREATE TABLE MyTablename

D'Arcy Rittich
- 167,292
- 40
- 290
- 283
87
I'm not a MySQL expert by any means but the following site suggests using the -d
or --no-data
option of mysqldump:
mysqldump -d -h localhost -u root -pmypassword databasename > dumpfile.sql
It worked for me.

Burhan Ali
- 2,258
- 1
- 28
- 38

mp31415
- 6,531
- 1
- 44
- 34
-
3I was looking for the answer to the original question, but I find this answer very helpful. – Sonny Jun 14 '14 at 15:41
9
if u have "MySQL Workbench" v6.0
1) click on any table of the database.
2) Right-click and select "Tables Maintenance"
3) Under "Tables" tab, highlight the tables u want to export, right-click and select "Send to SQL Editor">"Create Schema"

gan gary
- 167
- 1
- 6
2
It is already answered in the link below:
MySql export schema without data
Use the command below to take the structure or schema dump.
mysqldump -u root -p --no-data dbname > schema.sql

Community
- 1
- 1

Pramatha V
- 86
- 1
- 5