ALTER TABLE `test2` DROP PRIMARY KEY ,ADD PRIMARY KEY ( `id` )

重设主键字段

有时数据库操作时需要将一个主键修改为联合主键或者把主键改为其他列,这时候单纯的add primary key是没有用的,必须先删除主键约束再重新添加。

MYSQL:

1、alter table TABNAME drop primary key;

2、alter table TABNAME add primary key(another_col,...);

 

查看是否支持分区

SHOW VARIABLES LIKE '%partition%';

增加分区

ALTER TABLE apklog_submit
PARTITION BY RANGE ( TO_DAYS(up_date) ) (

PARTITION p0 VALUES LESS THAN ( TO_DAYS('2008-01-01 00:00:00') ),

PARTITION p1 VALUES LESS THAN ( TO_DAYS('2008-04-01 00:00:00') ),

PARTITION p2 VALUES LESS THAN ( TO_DAYS('2008-07-01 00:00:00') ),

PARTITION p3 VALUES LESS THAN ( TO_DAYS('2008-10-01 00:00:00') ),

PARTITION p4 VALUES LESS THAN ( TO_DAYS('2009-01-01 00:00:00') ),

PARTITION p5 VALUES LESS THAN ( TO_DAYS('2009-04-01 00:00:00') ),

PARTITION p6 VALUES LESS THAN ( TO_DAYS('2009-07-01 00:00:00') ),

PARTITION p7 VALUES LESS THAN ( TO_DAYS('2009-10-01 00:00:00') ),

PARTITION p8 VALUES LESS THAN ( TO_DAYS('2010-01-01 00:00:00') ),

PARTITION p9 VALUES LESS THAN (MAXVALUE)

);

技术
©2019-2020 Toolsou All rights reserved,
hive大量小文件处理方法总结最优化方法总结:公式解、数值优化、求解思想JavaScript中的 Call 和 Apply内存溢出和内存泄漏的区别、产生原因以及解决方案创建数据mysql库流程微信小程序(uni-app)url参数传递对象蝗灾虫群上亿只很少发生碰撞 蝗虫要成自动驾驶功臣vue 监听 Treeselect 选择项的改变第十一届蓝桥杯C/C++ 大学 B 组大赛软件类省赛服务器价格有什么差异?