本篇內(nèi)容主要講解“MySQL表結(jié)構(gòu)的復(fù)制方法”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“mysql表結(jié)構(gòu)的復(fù)制方法”吧!

創(chuàng)新互聯(lián)公司是一家專業(yè)提供永仁企業(yè)網(wǎng)站建設(shè),專注與成都做網(wǎng)站、網(wǎng)站制作、成都h5網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為永仁眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作公司優(yōu)惠進行中。
我們特別是oracle dbas常常會通過ctas來復(fù)制表結(jié)構(gòu),這樣復(fù)制出來的表實際上會丟掉表的一些屬性,索引就更不說了,在mysql中這樣來復(fù)制表其實得到的也只是表大體結(jié)構(gòu)而已。
還好mysql提供了create table like命令方便進行表結(jié)構(gòu)的復(fù)制,廢話不說了
root@mysql 02:55:17>use test
Database changed
root@test 03:25:22>create table t1(a int,b int,key (a)) engine=myisam;
Query OK, 0 rows affected (0.00 sec)
root@test 03:25:49>show create table t1G
*************************** 1. row ***************************
Table: t1
Create Table: CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk
1 row in set (0.00 sec)
root@test 03:25:55>create table t2 as select * from t1 where 1=0;
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0
root@test 03:26:16>show create table t2G
*************************** 1. row ***************************
Table: t2
Create Table: CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk
1 row in set (0.00 sec)
root@test 03:26:25>create table t3 like t1;
Query OK, 0 rows affected (0.00 sec)
root@test 03:26:44>show create table t3G
*************************** 1. row ***************************
Table: t3
Create Table: CREATE TABLE `t3` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk
1 row in set (0.00 sec)
到此,相信大家對“mysql表結(jié)構(gòu)的復(fù)制方法”有了更深的了解,不妨來實際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學習!
本文名稱:mysql表結(jié)構(gòu)的復(fù)制方法
標題URL:http://chinadenli.net/article20/gdpcco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護、服務(wù)器托管、微信公眾號、網(wǎng)站導航、營銷型網(wǎng)站建設(shè)、網(wǎng)站營銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)