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;
create table test_create_table_CreateAs as select * from test_create_table; 表结构的破坏 复制字段结构 复制表结构 LIKE的更多相关文章
- create table b1 as select * from b建表锁表测试
A: create table a1 like a; insert into a1 as select * from a; B: create table b1 as select * from b; ...
- create table:使用SELECT语句创建表
oracle下直接(创建表) create table newtablename as select * from oldtablename sqlserver的语法是(自动创建表) : select ...
- 用复制方式创建表 Create Table tbname as select * from user.tab where ...
用复制方式创建表 Create Table tbname as select * from user.tab where ...
- create table xxx as select 与 create table xxx like
create table xxx ) | NO | PRI | NULL | auto_increment | | Name | varchar() | NO | ...
- hive基本的操作语句(实例简单易懂,create table XX as select XX)
hive建表语句DML:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Cr ...
- create table repo_folder_operate_log_bak as select * from repo_folder_operate_log;
create table repo_folder_operate_log_bak as select * from repo_folder_operate_log;
- MongoDB 实现 create table tab2 as select
1. var result = db.foo.aggregate(...);db.bar.insert(result.result); 2. var temp1 = db.mtb1.find(name ...
- Oracle中的自连接(self join)-当表中的某一个字段与这个表中另外字段的相关时,我们可能用到自连接。
http://blog.163.com/wkyuyang_001/blog/static/10802122820091751049479/ 当表中的某一个字段与这个表中另外字段的相关时,我们可能用到自 ...
- oracle数据库【表复制】insert into select from跟create table as select * from 两种表复制语句区别
create table as select * from和insert into select from两种表复制语句区别 create table targer_table as select ...
随机推荐
- Spring Boot系列——Spring Boot如何启动
Spring Boot启动过程 上篇<Spring Boot系列--5分钟构建一个应用>介绍了如何快速创建一个Spring Boot项目并运行.虽然步骤少流程简单,为开发者省去了很多重复 ...
- makefile中的wildcard和notdir和patsubst
转自:https://blog.csdn.net/srw11/article/details/7516712 1.wildcard : 扩展通配符 2.notdir : 去除路径 3.patsubst ...
- idea svn 不见的问题
问题一: IntelliJ IDEA打开带SVN信息的项目不显示SVN信息,项目右键SVN以及图标还有Changes都不显示解决方法 在VCS菜单中有个开关,叫Enabled Version Cont ...
- 【网络编程】——ne-snmp开发实例1
net-snmp扩展有多种方式,在此只介绍两种——动态库扩展,静态库扩展. 在做net-snmp开发之前,首先确定net-snmp相关的软件是否安装. rpm -qa | grep snmp net- ...
- Java知多少(70)面向字节流的应用
文件输入输出流 文件输入输出流 FileInputStream 和 FileOutputStream 负责完成对本地磁盘文件的顺序输入输出操作. [例 10-5]通过程序创建一个文件,从键盘输入字符, ...
- Java知多少(97)绘图模式概述
绘图模式是指后绘制的图形与早先绘制的图形有重叠时,如何确定重叠部分的颜色.例如,后绘制的覆盖早先绘制的:或者后绘制与早先绘制的两种颜色按某种规则混合.主要有正常模式和异或模式两种:正常模式是后绘制的图 ...
- Foxpro数据库连接错误解决方法--【VFP DBF文件不是一个有效的路径。 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器】
直接访问vfp dbf文件时报错: 错误描述: 'd:\vfpData\test.dbf'不是一个有效的路径. 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器. 解决办法:Data Sour ...
- Java中浮点数的处理
import java.text.DecimalFormat; String addGold = String.valueOf(new DecimalFormat("0").for ...
- 设计模式 -创建型模式 ,python工厂模式 抽象工厂模式(1)
工厂模式 import xml.etree.ElementTree as etree import json class JSONConnector: def __init__(self, filep ...
- sshpass: 用于非交互的ssh 密码验证
ssh登陆不能在命令行中指定密码,也不能以shell中随处可见的,sshpass 的出现,解决了这一问题.它允许你用 -p 参数指定明文密码,然后直接登录远程服务器. 它支持密码从命令行,文件,环境变 ...