mysql 对已有表分区_mysql怎么对先有表进行分区

mysql如何对先有表进行分区?

有一张表,已经创建了,是一张普通的表,先要对这张表进行hash分区,我用一下语句创建提示错误:

mysql> alter table 33

-> partition by hash(id)

-> partitions 2;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '33

partition by hash(id)

partitions 2' at line 1

难道对普通标不能进行分区,必须要在创建表的时候指定分区类型?

------解决方案--------------------

你的表名是什么? 如果是33则需要加上 33 反引号(注意不是单引号)

SQL code

mysql> create table x ( -> id int primary key, -> c int -> ) engine=myisam; Query OK, 0 rows affected (0.10 sec) mysql> alter table x -> PARTITION BY HASH(id) -> PARTITIONS 2; Query OK, 0 rows affected (0.15 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql>

------解决方案--------------------

33为表名加引号。

alter table tb

partition by hash(id)

partitions 2;

------解决方案--------------------

33表名加''

alter table tb

partition by hash(id)

partitions 2;

欢迎大家阅读《mysql怎么对先有表进行分区》,跪求各位点评,by 搞代码

原创文章,转载请注明: 转载自搞代码

e7ce419cf2d6ad34d01da2ceb8829eed.png

微信 赏一包辣条吧~

023a57327877fb4402bcc76911ec18ea.png

支付宝 赏一听可乐吧~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值