Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The replication method of mysql table structure

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "the replication method of mysql table structure". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "the replication method of mysql table structure"!

We, especially oracle dbas, often copy the table structure through ctas, so the copied table will actually lose some properties of the table, not to mention the index. In mysql, replicating the table in this way will only get the general structure of the table.

Fortunately, mysql provides create table like commands to facilitate the replication of the table structure, so cut the crap.

Root@mysql 02:55:17 > use test

Database changed

Root@test 03:25:22 > create table T1 (an 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)

At this point, I believe that everyone on the "mysql table structure replication method" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report