naveen
naveen

Reputation: 1068

How to Create a Schema in MySQL?

How to create a schema with existing tables. I have 100 tables then now I want to create a schema for this table can you tell the procedure how or any tools.

I am trying the TOAD but it shows the result in HTML format. I want the result in SQL.

How create a schema using PHP.

Upvotes: 4

Views: 3664

Answers (6)

Krishan Gopal
Krishan Gopal

Reputation: 4133

You can use mysql workbench, connect with existing database there and you can import and export the schema in sql formats

Upvotes: 0

dhchen
dhchen

Reputation: 1198

A single show create table <tablename> statement in mysql command line tool will suffice, if you want schema only and no data. The result will be a full create table ddl

Upvotes: 1

Devart
Devart

Reputation: 122002

...can you tell the procedure how or any tools

You can use 'Generate Schema Script' or 'Backup' GUI tool in dbForge Studio for MySQL.

Limited Backup is available in free express version, the size of backup files is limited to 1MB, it is enough for 100 table schemas.

Upvotes: 0

Flavius
Flavius

Reputation: 13816

http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html#option_mysqldump_no-data

That is:

mysqldump --no-data -u <username> -p --database <dbname> <further options> > <dbname>.sql

from the command line, on the server (perhaps via ssh).

Upvotes: 0

Nishant
Nishant

Reputation: 55866

mysqldump --user MYSQL_USER --password=MYSQL_PASSWORD --add-locks --flush-privileges \
--add-drop-table --complete-insert --extended-insert --single-transaction \
--database DB_TO_BACKUP > FILENAME_FOR_SQL_STATEMENTS

this will give a file full of SQL create and insert statements that can be used to recreate the DB. The back slashes "\" are continue to next line... you may want to ignore it and write the whole command in one line

Now, I am not sure if you wanted to the whole Db with data or just tables... you may want to use --no-data to get rid of insert SQL statements and just create and delete (and lock) statements, e.g.

mysqldump --user MYSQL_USER --password=MYSQL_PASSWORD --add-locks --flush-privileges \
--add-drop-table --no-data --single-transaction \
--database DB_TO_BACKUP > FILENAME_FOR_SQL_STATEMENTS

Upvotes: 0

Sandy8086
Sandy8086

Reputation: 643

Take Dump of all table so you get schema...refer this Dump

mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

Upvotes: 0

Related Questions