91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何用pt-online-schema-change在線修改表字段長度

發布時間:2020-08-11 04:48:07 來源:ITPUB博客 閱讀:189 作者:chenfeng 欄目:MySQL數據庫
pt-online-schema-change依賴條件:
操作的表必須有主鍵,否則執行會報錯

實驗如下:
MySQL [mysql]> create database chenfeng;
Query OK, 1 row affected (0.00 sec)

MySQL [mysql]> use chenfeng;
Database changed

創建帶有主鍵的表test:
MySQL [chenfeng]> create table test
    -> (id int(10) not null auto_increment,
    -> k int(10) not null default '0',
    -> c char(120) not null default '',
    -> primary key(id))
    -> engine=innodb default charset=utf8;
Query OK, 0 rows affected (0.03 sec)


MySQL [chenfeng]> desc test;
+-------+-----------+------+-----+---------+----------------+
| Field | Type      | Null | Key | Default | Extra          |
+-------+-----------+------+-----+---------+----------------+
| id    | int(10)   | NO   | PRI | NULL    | auto_increment |
| k     | int(10)   | NO   |     | 0       |                |
| c     | char(120) | NO   |     |         |                |
+-------+-----------+------+-----+---------+----------------+
3 rows in set (0.01 sec)


MySQL [chenfeng]> 

MySQL [chenfeng]> show create table test\G
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `k` int(10) NOT NULL DEFAULT '0',
  `c` char(120) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)


[root@chenfeng ~]# pt-online-schema-change --alter="modify c varchar(150) not null default ''" --user=root --password=123456 D=chenfeng,t=test --charset=utf8 --execute
No slaves found.  See --recursion-method if host chenfeng has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
  analyze_table, 10, 1
  copy_rows, 10, 0.25
  create_triggers, 10, 1
  drop_triggers, 10, 1
  swap_tables, 10, 1
  update_foreign_keys, 10, 1
Altering `chenfeng`.`test`...
Creating new table...
Created new table chenfeng._test_new OK.
Altering new table...
Altered `chenfeng`.`_test_new` OK.
2016-10-07T18:57:36 Creating triggers...
2016-10-07T18:57:36 Created triggers OK.
2016-10-07T18:57:36 Copying approximately 1 rows...
2016-10-07T18:57:36 Copied rows OK.
2016-10-07T18:57:36 Analyzing new table...
2016-10-07T18:57:36 Swapping tables...
2016-10-07T18:57:36 Swapped original and new tables OK.
2016-10-07T18:57:36 Dropping old table...
2016-10-07T18:57:36 Dropped old table `chenfeng`.`_test_old` OK.
2016-10-07T18:57:36 Dropping triggers...
2016-10-07T18:57:36 Dropped triggers OK.
Successfully altered `chenfeng`.`test`.
[root@chenfeng ~]# 


MySQL [(none)]> use chenfeng
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
MySQL [chenfeng]> show tables;
+-----------------+
| Tables_in_chenfeng |
+-----------------+
| test            |
+-----------------+
1 row in set (0.00 sec)


MySQL [chenfeng]> desc test;
+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| id    | int(10)      | NO   | PRI | NULL    | auto_increment |
| k     | int(10)      | NO   |     | 0       |                |
| c     | varchar(150) | NO   |     |         |                |
+-------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

varchar(150)即為我們想要的結果。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

兴化市| 普陀区| 泰来县| 清水县| 图们市| 广元市| 通江县| 湖州市| 清苑县| 察雅县| 大余县| 福清市| 绍兴市| 武穴市| 石城县| 荔浦县| 全州县| 文登市| 宁陵县| 诸暨市| 吉木萨尔县| 那曲县| 资源县| 东阳市| 辽源市| 贡觉县| 连州市| 乾安县| 正宁县| 随州市| 施秉县| 彰武县| 西峡县| 龙州县| 察哈| 徐州市| 庆城县| 连云港市| 鄂州市| 荣昌县| 日土县|