I'm trying to change the data type bigint(37) to int(11) here. I've tried several methods CAST or CONVERT but ended unsuccessfully.
How can I change the datatype here in this table VIEW? please. thanks.
CREATE OR REPLACE VIEW gtemp_view AS
SELECT
d1.Week AS Week1,
d2.Week AS Week2,
IF( ABS(d1.dt1-d2.dt1)=0,1,0) +
IF( ABS(d1.dt1-d2.dt2)=0,1,0) +
IF( ABS(d1.dt1-d2.dt3)=0,1,0) +
IF( ABS(d1.dt1-d2.dt4)=0,1,0) +
IF( ABS(d1.dt2-d2.dt1)=0,1,0) +
IF( ABS(d1.dt2-d2.dt2)=0,1,0) +
IF( ABS(d1.dt2-d2.dt3)=0,1,0) +
IF( ABS(d1.dt2-d2.dt4)=0,1,0) +
IF( ABS(d1.dt3-d2.dt1)=0,1,0) +
IF( ABS(d1.dt3-d2.dt2)=0,1,0) +
IF( ABS(d1.dt3-d2.dt3)=0,1,0) +
IF( ABS(d1.dt3-d2.dt4)=0,1,0) +
IF( ABS(d1.dt4-d2.dt1)=0,1,0) +
IF( ABS(d1.dt4-d2.dt2)=0,1,0) +
IF( ABS(d1.dt4-d2.dt3)=0,1,0) +
IF( ABS(d1.dt4-d2.dt4)=0,1,0) AS mcount
FROM gtemp AS d1 , gtemp AS d2 WHERE d1.Week IS NOT NULL AND d2.Week IS NOT NULL AND d1.Week > d2.Week order by Week1 DESC, Week2 DESC limit 200000;
If you don't want see INT37 in view schema you could try using an explict cast as unsigned
CREATE OR REPLACE VIEW gtemp_view AS
SELECT
d1.Week AS Week1,
d2.Week AS Week2,
cast(
(IF( ABS(d1.dt1-d2.dt1)=0,1,0) +
IF( ABS(d1.dt1-d2.dt2)=0,1,0) +
IF( ABS(d1.dt1-d2.dt3)=0,1,0) +
IF( ABS(d1.dt1-d2.dt4)=0,1,0) +
IF( ABS(d1.dt2-d2.dt1)=0,1,0) +
IF( ABS(d1.dt2-d2.dt2)=0,1,0) +
IF( ABS(d1.dt2-d2.dt3)=0,1,0) +
IF( ABS(d1.dt2-d2.dt4)=0,1,0) +
IF( ABS(d1.dt3-d2.dt1)=0,1,0) +
IF( ABS(d1.dt3-d2.dt2)=0,1,0) +
IF( ABS(d1.dt3-d2.dt3)=0,1,0) +
IF( ABS(d1.dt3-d2.dt4)=0,1,0) +
IF( ABS(d1.dt4-d2.dt1)=0,1,0) +
IF( ABS(d1.dt4-d2.dt2)=0,1,0) +
IF( ABS(d1.dt4-d2.dt3)=0,1,0) +
IF( ABS(d1.dt4-d2.dt4)=0,1,0))
AS UNIGNED) mcount
FROM gtemp AS d1 , gtemp AS d2
WHERE d1.Week IS NOT NULL
AND d2.Week IS NOT NULL
AND d1.Week > d2.Week
order by Week1 DESC, Week2 DESC limit 200000;
anyway the cast should impact on performance in several way ..instead the INT37 datatype don't should produce appretiable performance degrade
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.