How to copy table between two models in Mysql workbench?
- Select tab with source database
- In menu: Server->Data Export
- Select Schema and the Table as Schema Object
- Select option Export to Self-Contained File and check Create Dump in a Single Transaction (self-contained only)
- Copy full file path to clipboard
- Start Export
- Select tab with target database
- In menu: Server->Data Import. Make sure your target database name is at the top left corner of the Data Import view
- Select Import from self contained file and paste full file path from clipboard
- Select Default Target Schema
- Select Dump Content (Dump Structure and Data etc…)
- Start Import
If you just want to do a single table through the MySQL Workbench.
In MySQL Workbench:
- Connect to a MySQL Server
- Expand a Database
- Right Click on a table
- Select Copy To Clipboard
- Select Create Statement
A create statement for the table will be copied to your clipboard similar to the below:
CREATE TABLE `cache` (
`cid` varchar(255) NOT NULL DEFAULT '',
`data` longblob,
`expire` int(11) NOT NULL DEFAULT '0',
`created` int(11) NOT NULL DEFAULT '0',
`headers` text,
`serialized` smallint(6) NOT NULL DEFAULT '0',
PRIMARY KEY (`cid`),
KEY `expire` (`expire`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Create the table in the new database
- Open a new SQL tab for executing queries (File->New Query Tab)
Alter the create table code to include the database to create the table on.
CREATE TABLE `databaseName`.`cache` ( `cid` varchar(255) NOT NULL DEFAULT '', `data` longblob, `expire` int(11) NOT NULL DEFAULT '0', `created` int(11) NOT NULL DEFAULT '0', `headers` text, `serialized` smallint(6) NOT NULL DEFAULT '0', PRIMARY KEY (`cid`), KEY `expire` (`expire`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Then click the Execute button (looks like a lightening Bolt)
That will copy the table schema from one db to another using the MySQL workbench. Just refresh the tables in the database and you should see your newly added table