MySQL修改,表結構大幅修改

來源:互聯網
上載者:User

標籤:封面   arch   origin   const   column   cat   下載伺服器   set   mysql   

------------------
create table t_video_file_temp
(
video_id bigint not null comment ‘視頻Id‘,
file_md5 varchar(64) comment ‘視頻md5‘,
file_size bigint comment ‘視頻大小‘,
source_url varchar(500) comment ‘視頻源地址‘,
file_url varchar(500) comment ‘視頻本地地址‘,
status tinyint(2) default 0 comment ‘0待審核,1待採集,2採集中,3採集成功,4採集失敗,5上傳伺服器並轉碼成功‘,
check_time timestamp comment ‘審核時間‘,
origin tinyint(3) comment ‘來源‘,
source_id varchar(50) comment ‘來源Id‘,
download_time timestamp comment ‘下載時間‘,
service_ip varchar(50) comment ‘下載伺服器標識‘,
repeat_id bigint comment ‘重複Id‘,
repeat_status tinyint(1) default 0 comment ‘0未檢測,1重複,2不重複‘,
source_img_url varchar(500) comment ‘圖片源url‘,
img_url varchar(500) comment ‘圖片地址‘,
primary key (video_id)
);
------------------
1-匯入SQL檔案
2-建表,執行SQL 。
INSERT INTO `t_video_file_temp`(`video_id`,`file_md5`,`file_size`,`source_url`,`file_url`,`status`,`check_time`,`origin`,`source_id`,`download_time`,`service_ip`,`repeat_id`,`repeat_status`,`source_img_url`,`img_url`)
SELECT v.video_id,f.file_md5 ,f.file_size,f.source_url,f.file_url,f.status,f.check_time,f.origin, ext.source_id ,f.download_time,f.service_ip,f.repeat_id,f.repeat_status,img.source_url,f.file_url
FROM t_video v
JOIN t_video_file AS f ON f.file_id = v.video_file_id
JOIN t_video_ext ext ON ext.video_id = v.video_id
LEFT JOIN t_video_file AS img ON v.img_file_id=img.file_id;
-- t_video狀態為4的改為2
update t_video t set t.status = 2 where t.status = 4;

-- 增加欄位,審核使用者名稱,是否刪除,刪除使用者名稱,刪除時間
ALTER TABLE `t_video` ADD COLUMN `user_name` varchar(50) ;
ALTER TABLE `t_video` ADD COLUMN `is_delete` tinyint(1) default 0 comment ‘1刪除‘ ;
ALTER TABLE `t_video` ADD COLUMN `delete_user_name` varchar(50) ;
ALTER TABLE `t_video` ADD COLUMN `delete_time` timestamp NULL default NULL ;
-- 刪除主外鍵,
ALTER TABLE `t_video` DROP FOREIGN KEY `FK_Reference_2`;
ALTER TABLE `t_video` DROP FOREIGN KEY `FK_Reference_3`;
-- 刪除視頻檔案ID ,封面圖片ID
alter table `t_video` drop column `img_file_id` ;
alter table `t_video` drop column `video_file_id` ;
alter table `t_video` drop column `userId` ;
-- 修改t_video_file名稱 如:t_video_file_qaz 。還原t_video_file_temp表名
alter table t_video_file rename t_video_file_qaz ;
alter table t_video_file_temp rename t_video_file ;
-- t_video_ext 增加欄位 發布時間
ALTER TABLE `t_video_ext` ADD COLUMN `release_time` timestamp NULL default NULL ;
-- ---------------------------------------

ALTER TABLE `t_video`
MODIFY COLUMN `video_id` bigint(20) NOT NULL AUTO_INCREMENT FIRST ;

ALTER TABLE `t_video_ext`
MODIFY COLUMN `classification` varchar(30) NULL DEFAULT NULL COMMENT ‘1搞笑,2美食,3,動物圈,4運動,5鬼畜調教,6美妝,7服飾,8健身,9資訊,10明星,11Korea相關,12電影相關,13電視劇‘ AFTER `source_url`;

-- 增加外鍵
ALTER TABLE `t_video_ext` ADD CONSTRAINT `FK_Reference_1` FOREIGN KEY (`video_id`) REFERENCES `t_video` (`video_id`);

-- 增加外鍵
ALTER TABLE `t_video_file` ADD CONSTRAINT `FK_Reference_5` FOREIGN KEY (`video_id`) REFERENCES `t_video` (`video_id`);

MySQL修改,表結構大幅修改

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.