开发者

Data loss possible with mysql alter command?

While I don't think data loss is possible, I want to double check if the following queries can cause data loss. I am adding indexes and increase varchar length.

ALTER TABLE  `phppos_sales` ADD  `deleted` INT( 1 ) NOT NULL DEFAULT  '0';
ALTER TABLE  `phppos_items` ADD INDEX (  `name` );
ALTER TABLE  `phppos_items` ADD INDEX (  `category` );
ALTER TABLE  `phppos_items` ADD INDEX (  `deleted` );
ALTER TABLE  `phppos_customers` ADD INDEX (  `deleted` );
ALTER TABLE  `phppos_employees` ADD INDEX (  `deleted` );
ALTER TABLE  `phppos_giftcards` ADD INDEX (  `deleted` );
ALTER TABLE  `phppos_item_kits` ADD INDEX (  `name` );
ALTER TABLE  `phppos_people` ADD INDEX (  `first_name` );
ALTER TABLE  `phppos_people` ADD INDEX (  `last_name` );
ALTER TABLE  `phppos_people` ADD INDEX (  `email` );
ALTER TABLE  `phppos_sales` ADD INDEX (  `deleted` );
ALTER TABLE  `phppos_suppliers` ADD INDEX (  `deleted` );
ALTER TABLE  `phppos_receivings` CHANGE  `payment_type`  `payment_type` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_receivings_items` CHANGE  `description`  `description` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_receivings_items` CHANGE  `serialnumber`  `serialnumber` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_sales` CHANGE  `payment_type`  `payment_type` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_sales_suspended` CHANGE  `payment_type`  `payment_type` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_giftcards` CHANGE  `giftcard_number`  `giftcard_number` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
ALTER TABLE  `phppos_sales_items` CHANGE  `description`  `description` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_sales_items` CHANGE  `serialnumber`  `serialnumber` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_sales_suspended_items` CHANGE  `description`  `description` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_sales_suspended_items` CHANGE  `serialnumber`  `serialnumber` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
ALTER TABLE  `phppos_sales_suspended_payments` CHANGE  `payment_type`  `pay开发者_JS百科ment_type` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;
ALTER TABLE  `phppos_sales_payments` CHANGE  `payment_type`  `payment_type` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;


In any case, you should compare the data before and after the operation.

Do mysqldump --extended-insert=FALSE ... > old.sql before the change, and the same > new.sql after the change, and then diff -u old.sql new.sql | less to be sure.

The extended-insert=FALSE part is needed to place every table row on the separate line for easier diff'ing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜