当前位置:   article > 正文

MySql DDL_mysql主备节点能同步 ddl

mysql主备节点能同步 ddl

DDL : Data Definition Language
用途:
用于描述数据库中存储的现实世界实体的语言。即创建数据库和表的结构。

CREATE ALTER DROP TRUNCATE
CREATE {DATABASE | SCHEMA } [ IF NOT EXISTS ] 数据库名称

CREATE DATABASE IF NOT EXISTS mydb3 CHARACTER SET utf8 COLLATE utf8_general_ci;

mysql> SHOW CREATE DATABASE mydb1;
±---------±---------------------------------------------------------------+
| Database | Create Database |
±---------±---------------------------------------------------------------+
| mydb1 | CREATE DATABASE mydb1 /*!40100 DEFAULT CHARACTER SET utf8 / |
±---------±---------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql>
mysql>
mysql>
mysql> SHOW CREATE DATABASE mydb2;
±---------±--------------------------------------------------------------+
| Database | Create Database |
±---------±--------------------------------------------------------------+
| mydb2 | CREATE DATABASE mydb2 /
!40100 DEFAULT CHARACTER SET gbk / |
±---------±--------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SHOW CREATE DATABASE mydb3;
±---------±---------------------------------------------------------------+
| Database | Create Database |
±---------±---------------------------------------------------------------+
| mydb3 | CREATE DATABASE mydb3 /
!40100 DEFAULT CHARACTER SET utf8 */ |
±---------±---------------------------------------------------------------+
1 row in set (0.00 sec)

查询
SHOW DATABASES;
SHOW CREATE DATABASE 数据库名称;

删除
DROP DATABASE 数据库名称;
mysql> SHOW CREATE DATABASE mydb3;
±---------±---------------------------------------------------------------+
| Database | Create Database |
±---------±---------------------------------------------------------------+
| mydb3 | CREATE DATABASE mydb3 /*!40100 DEFAULT CHARACTER SET utf8 */ |
±---------±---------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> DROP DATABASE IF EXISTS mydb3;
Query OK, 0 rows affected (0.02 sec)
mysql> SHOW DATABASES;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mydb1 |
| mydb2 |
| mysql |
| test |
±-------------------+
5 rows in set (0.00 sec)

修改
ALERT
mysql> SHOW CREATE DATABASE mydb1;
±---------±---------------------------------------------------------------+
| Database | Create Database |
±---------±---------------------------------------------------------------+
| mydb1 | CREATE DATABASE mydb1 /*!40100 DEFAULT CHARACTER SET utf8 / |
±---------±---------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> ALTER DATABASE mydb2 CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql> SHOW CREATE DATABASE mydb2;
±---------±---------------------------------------------------------------+
| Database | Create Database |
±---------±---------------------------------------------------------------+
| mydb2 | CREATE DATABASE mydb2 /
!40100 DEFAULT CHARACTER SET utf8 */ |
±---------±---------------------------------------------------------------+
1 row in set (0.00 sec)

来源:
http://www.360doc.com/content/20/0123/19/57605256_887619259.shtml

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/538994
推荐阅读
相关标签
  

闽ICP备14008679号