Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql workbench copy table structure

44

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
Comment

PREVIOUS NEXT
Code Example
Sql :: PL SQL Adding elements to VARRAY from a cursor 
Sql :: unpdate pl sql 
Sql :: hierachichal sql query 
Sql :: subconjuntos da linguagem SQL 
Sql :: Convert LDAP Epoch to Date 
Sql :: oracle test if 0 
Sql :: how to import sqlite driver class in java using maven 
Sql :: select count(*) from table 
Sql :: my sql data file extention 
Sql :: heavy table in mysql 
Sql :: cannot cast type numeric to boolean postgresql 
Sql :: how much table store postgres 
Sql :: convert sql query to linq online 
Sql :: resullt all update knex mysql 
Sql :: creating a joined view in mysql 
Sql :: online t-sql editor 
Sql :: database db connection string format 
Sql :: Raw into column 
Sql :: azure sql server check foreign key 
Sql :: fetch second word from a string in ms sql 
Sql :: How to select only the first rows for each unique value of a sql tablecolumn? 
Sql :: Extend the 2.1 case study to implement below listed queries. Write separate operations/method to implement each query. a.Query all books in database. 
Sql :: tsql table column constraint must be uppercase 
Sql :: SOQL Parent to child 
Sql :: how to import datadd in sql 
Sql :: mysql select top 2 
Sql :: replace sqlalchemy 
Sql :: SQLAlchemy query to return only n results? 
Sql :: liquibase default-schema in sql 
Sql :: learn sqlite dart 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =