------------------
CREATE TABLE T_video_file_temp
(
video_id bigint not NULL comment ' video ID ',
FILE_MD5 varchar (comment) ' video MD5 ',
file_size bigint comment ' video size ',
Source_url varchar (+) Comment ' video source address ',
File_url varchar (+) Comment ' video local address ',
Status tinyint (2) default 0 comment ' 0 pending review, 1 pending acquisition, 2 acquisition, 3 acquisition success, 4 acquisition failure, 5 upload server and transcoding success ',
Check_time Timestamp comment ' Audit time ',
Origin tinyint (3) Comment ' source ',
source_id varchar (comment ' source id '),
Download_time timestamp comment ' Download time ',
Service_ip varchar (comment ' Download server identity '),
repeat_id bigint comment ' duplicate ID ',
Repeat_status tinyint (1) Default 0 comment ' 0 not detected, 1 repeats, 2 not duplicated ',
Source_img_url varchar (+) Comment ' picture source URL ',
Img_url varchar (+) Comment ' picture address ',
Primary KEY (VIDEO_ID)
);
------------------
1-Import SQL file
2-Build table, execute 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 joins T_video_file as IMG on v.img_file_id=img.file_id;
--T_video status of 4 changed to 2
Update T_video t Set t.status = 2 where t.status = 4;
--Add field, audit user name, delete, delete user name, delete time
ALTER TABLE ' t_video ' ADD COLUMN ' user_name ' varchar;
ALTER TABLE ' t_video ' ADD COLUMN ' is_delete ' tinyint (1) Default 0 comment ' 1 delete ';
ALTER TABLE ' t_video ' ADD COLUMN ' delete_user_name ' varchar (50);
ALTER TABLE ' t_video ' ADD COLUMN ' delete_time ' timestamp null default null;
--Delete the primary foreign key,
ALTER TABLE ' t_video ' DROP FOREIGN key ' fk_reference_2 ';
ALTER TABLE ' t_video ' DROP FOREIGN KEY ' fk_reference_3 ';
--delete video file ID, cover picture 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 ';
--Modify the T_video_file name such as: T_video_file_qaz. Restore the T_VIDEO_FILE_TEMP table name
ALTER TABLE t_video_file rename T_video_file_qaz;
ALTER TABLE t_video_file_temp rename T_video_file;
--t_video_ext increase field publish time
ALTER TABLE ' t_video_ext ' Add COLUMN ' release_time ' timestamp null default null;
-- ---------------------------------------
ALTER TABLE ' T_video '
MODIFY COLUMN ' video_id ' bigint (a) not NULL auto_increment first;
ALTER TABLE ' T_video_ext '
MODIFY COLUMN ' classification ' varchar (+) null DEFAULT null COMMENT ' 1 funny, 2 food, 3, animal ring, 4 sport, 5 ghost Husbandry, 6 beauty, 7 costumes, 8 Fitness, 9 News, 10 stars, 11Korea related, 12 movie related, 13 drama ' after ' Source_url ';
--Add foreign keys
ALTER TABLE ' t_video_ext ' ADD CONSTRAINT ' fk_reference_1 ' FOREIGN KEY (' video_id ') REFERENCES ' t_video ' (' video_id ');
--Add foreign keys
ALTER TABLE ' t_video_file ' ADD CONSTRAINT ' fk_reference_5 ' FOREIGN KEY (' video_id ') REFERENCES ' t_video ' (' video_id ');
MySQL modified, table structure greatly modified