How to reset mysql table structure without data with SQL query?

I need to export a mysql table, but it has 5gb of records, so I only need a structure. I am trying to do this from a simple php executing a sql query, how can I do this?

+43
database mysql
Nov 27 '10 at 23:33
source share
5 answers

You can use SHOW CREATE TABLE for this.

Shows the CREATE TABLE statement that creates this table. The statement requires SELECT privilege for the table. Starting with MySQL 5.0.1, this statement also works with views.

eg:.

 SHOW CREATE TABLE MyTablename 
+76
Nov 27 '10 at 23:37
source share

I am not a MySQL expert in any way, but the following site suggests using the -d or --no-data option for mysqldump:

 mysqldump -d -h localhost -u root -pmypassword databasename > dumpfile.sql 

It worked for me.

+48
Sep 16 '12 at 16:57
source share

if u has "MySQL Workbench" v6.0

1) click on any database table.

2) Right-click and select "Table Maintenance"

3) On the Tables tab, highlight the tables you want to export, right-click and select Send to SQL Editor> Create Schema

+3
Sep 26 '13 at 8:35
source share

The answer is already indicated at the following link:
MySql export scheme without data

Use the command below to dump a structure or circuit.

 mysqldump -u root -p --no-data dbname > schema.sql 
0
May 02 '17 at 9:24 a.m.
source share

Depending on your exact requirements, something as simple as

 select * from table where 1=0 

may be enough.

-9
Nov 27 '10 at 23:41
source share



All Articles