Mellon
Mellon

Reputation: 38842

dump out some tables of the database

I am using MySQL v5.1 on Ubuntu machine.

I have a database named db_test which contain tables like cars, customers, departments, prices , and so on.

I know I can use the following commands to dump out the db_test database and dump the database back into a new database in following way:

mysqldump -u username -p -v db_test > db_test.sql
mysqladmin -u username -p create new_database
mysql -u username -p new_database < db_test.sql

But for my new_database , I only needs some tables from db_test database, not all the tables.

So, How can I dump out some tables from db_test database and dump these tables back to my new_database ?

Upvotes: 0

Views: 263

Answers (3)

dku.rajkumar
dku.rajkumar

Reputation: 18568

please use below code:

mysqldump -u username -p -v db_test[table1, table2,....] > db_test.sql

Upvotes: 1

Matt Fenwick
Matt Fenwick

Reputation: 49085

From the MySQL docs:

shell> mysqldump [options] db_name [tbl_name ...]

List the names of the tables after the database name; listing no table names results in all tables being dumped.

Upvotes: 1

Martin Vejmelka
Martin Vejmelka

Reputation: 458

Simply list the tables in the mysqldump command.

Upvotes: 0

Related Questions