zoukankan      html  css  js  c++  java
  • create table test_create_table_CreateAs as select * from test_create_table; 表结构的破坏 复制字段结构 复制表结构 LIKE

    案例中:

    索引丢失、分区丢失

    实际测试

    Target Server Type : MYSQL
    Target Server Version : 50616
    File Encoding : 65001

    Date: 2019-03-20 15:08:45
    */

    SET FOREIGN_KEY_CHECKS=0;

    -- ----------------------------
    -- Table structure for test_create_table
    -- ----------------------------
    DROP TABLE IF EXISTS `test_create_table`;
    CREATE TABLE `test_create_table` (
    `uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
    `pv` smallint(6) NOT NULL DEFAULT '0' COMMENT '浏览总量',
    `ip` bigint(20) NOT NULL DEFAULT '0' COMMENT 'ip',
    `date` date NOT NULL DEFAULT '0000-00-00' COMMENT '日期',
    KEY `idx_uid` (`uid`),
    KEY `date` (`date`),
    KEY `uid_date` (`uid`,`date`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='访问页面统计总表';

    -- ----------------------------
    -- Records of test_create_table
    -- ----------------------------
    INSERT INTO `test_create_table` VALUES ('435345', '0', '0', '2019-02-27');
    INSERT INTO `test_create_table` VALUES ('5464', '0', '0', '2019-03-14');

    Target Server Type : MYSQL
    Target Server Version : 50616
    File Encoding : 65001

    Date: 2019-03-20 15:11:24
    */

    SET FOREIGN_KEY_CHECKS=0;

    -- ----------------------------
    -- Table structure for test_create_table_createas
    -- ----------------------------
    DROP TABLE IF EXISTS `test_create_table_createas`;
    CREATE TABLE `test_create_table_createas` (
    `uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
    `pv` smallint(6) NOT NULL DEFAULT '0' COMMENT '浏览总量',
    `ip` bigint(20) NOT NULL DEFAULT '0' COMMENT 'ip',
    `date` date NOT NULL DEFAULT '0000-00-00' COMMENT '日期'
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    -- ----------------------------
    -- Records of test_create_table_createas
    -- ----------------------------
    INSERT INTO `test_create_table_createas` VALUES ('435345', '0', '0', '2019-02-27');
    INSERT INTO `test_create_table_createas` VALUES ('5464', '0', '0', '2019-03-14');

    索引丢失

    create table test_create_table_CreateLike LIKE test_create_table;
    insert into test_create_table_CreateLike SELECT * FROM test_create_table;

    复制结构

    Target Server Type : MYSQL
    Target Server Version : 50616
    File Encoding : 65001

    Date: 2019-03-20 15:31:48
    */

    SET FOREIGN_KEY_CHECKS=0;

    -- ----------------------------
    -- Table structure for test_create_table_createlike
    -- ----------------------------
    DROP TABLE IF EXISTS `test_create_table_createlike`;
    CREATE TABLE `test_create_table_createlike` (
    `uid` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
    `pv` smallint(6) NOT NULL DEFAULT '0' COMMENT '浏览总量',
    `ip` bigint(20) NOT NULL DEFAULT '0' COMMENT 'ip',
    `date` date NOT NULL DEFAULT '0000-00-00' COMMENT '日期',
    KEY `idx_uid` (`uid`),
    KEY `date` (`date`),
    KEY `uid_date` (`uid`,`date`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='访问页面统计总表';

    -- ----------------------------
    -- Records of test_create_table_createlike
    -- ----------------------------
    INSERT INTO `test_create_table_createlike` VALUES ('435345', '0', '0', '2019-02-27');
    INSERT INTO `test_create_table_createlike` VALUES ('5464', '0', '0', '2019-03-14');

    插入数据

    drop table if EXISTS test_create_table_CreateLike;

  • 相关阅读:
    树莓派测试摄像头
    React Native入坑记录
    2016总结及2017计划
    C#操作Excel
    IntelliJ配置SpringMVC提示“found:java.lang.String required:java.lang.String”
    opencv手工编译
    iOS webview注入JS
    C#生成exe、dll版本号自动增加
    iOS 允许po打印frame等内容
    2015总结及2016计划
  • 原文地址:https://www.cnblogs.com/rsapaper/p/10565092.html
Copyright © 2011-2022 走看看