a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 數(shù)據(jù)庫 > 文庫 > 正文

如何用pt-online-schema-change在線修改表字段長(zhǎng)度

2024-09-07 22:12:32
字體:
供稿:網(wǎng)友
       pt-online-schema-change依賴條件:
       操作的表必須有主鍵,否則執(zhí)行會(huì)報(bào)錯(cuò)
 
       實(shí)驗(yàn)如下:
MySQL [mysql]> create database chenfeng;
Query OK, 1 row affected (0.00 sec)
 
MySQL [mysql]> use chenfeng;
Database changed
 
      創(chuàng)建帶有主鍵的表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)即為我們想要的結(jié)果。

(編輯:武林網(wǎng))

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 亚洲精品在线播放视频 | 精品国产一区二区三区久久久 | 亚洲精品一区二区在线观看 | 日韩色综合 | 国产精品美女在线观看直播 | 免费国产网站 | 成人sese | 日本不卡视频 | 欧美精品在线免费观看 | 中文字幕免费在线 | 精品人人 | 伊人艹| 亚洲第一国产精品 | 深夜成人小视频 | 密室大逃脱第六季大神版在线观看 | 中文字幕在线一区 | 九九天堂| www.huangse | 久久免费精品 | 久久精品国产清自在天天线 | 亚洲电影在线观看 | 久久综合久色欧美综合狠狠 | 亚洲欧美一级 | 亚洲片在线观看 | 91精品电影 | 黄色影音| 国产伦精品一区二区三区照片91 | 欧美xo影院 | 一级淫片免费 | 狠狠操天天操 | 久久久av电影 | 日本午夜电影 | 久久久亚洲天堂 | 中文字幕一区二区三区乱码图片 | 久久极品| 久久伊人操 | 欧美一区二区三区精品 | 国产二区在线播放 | 亚洲人人舔人人 | 91久久国产精品 | 国产精品久久久久久久久福交 |