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 搞代碼
原創文章,轉載請注明: 轉載自搞代碼
微信 賞一包辣條吧~
支付寶 賞一聽可樂吧~
總結
以上是生活随笔為你收集整理的mysql 对已有表分区_mysql怎么对先有表进行分区的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 309 元,黑峡谷推出 X4 机械键盘:
- 下一篇: linux cmake编译源码,linu