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 ...
随机推荐
- Atitit 计算word ppt文档的页数
Atitit 计算word ppt文档的页数 http://localhost:8888/ http://git.oschina.net/attilax/ati_wordutil private vo ...
- Atitit 技术经理职责与流程表总结
Atitit 技术经理职责与流程表总结 1. (最重要) 理念 价值观建设 ***团队文化建设2 1.1. 加强跨项目组员沟通 ,防止重复劳动2 1.2. 活动聚餐2 2. (重要)方向建设 技术 ...
- Java知多少(8)类库及其组织结构
Java 官方为开发者提供了很多功能强大的类,这些类被分别放在各个包中,随JDK一起发布,称为Java类库或Java API. API(Application Programming Interfac ...
- linux命令后加一个 &
默认情况下,进程是在前台运行的,这时就把shell给占据了,我们无法进行其它操作.对于那些没有交互的进程,很多时候,我们希望将其在后台启动,可以在启动参数的时候加一个'&'实现这个目的. ti ...
- Docker GitLab镜像部署
环境说明 系统环境: CentOS Linux release 7.4 docker Version: 18.03.1-ce 运行镜像 docker run --detach \ --hostname ...
- 零基础 Vue 开发环境搭建 打开运行Vue项目
[相关推荐]IntellIJ IDEA 配置 Vue 支持 打开Vue项目 所需文件 node.js环境(npm包管理器)(node-v8.11.3-x64.msi)(npmV5.6.0) cnpm ...
- js实现选中文字 分享功能
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- Orchard CMS -Migration文件更新后数据库不更新的问题 new properties not updating after migrationData migration is not working?
Orchard CMS - new properties not updating after migrationData migration is not working? If your mapp ...
- laravel 在linux环境下解决.htaccess无效和去除index.php
LoadModule rewrite_module modules/mod_rewrite.so (去掉前面的#注释) AllowOverride All (根目录的配置下,确保设置成All) < ...
- [React] 03 - Intro: react.js in twelve demos
Ref: React 入门实例教程 这算什么,react学习例子的十二门徒?哈哈 如何运行别人的react项目? Ref: [React全家桶入门之CODE]项目代码与使用方法 使用git克隆项目到本 ...