开发者

MySql - Create a view with longtext cast into VARCHAR(255)

开发者 https://www.devze.com 2023-02-21 00:39 出处:网络
I am willing to create a view on a table with a longtext column. But I would like that in my view this column be varchar(255). And Yes I would like 开发者_开发技巧to cut the \"extra\" text.

I am willing to create a view on a table with a longtext column. But I would like that in my view this column be varchar(255). And Yes I would like 开发者_开发技巧to cut the "extra" text.

When I do a substr in the create script the data type is still longtext

Anyone could help me ?

Thanks


How about casting the longtext as a varchar?

 CREATE VIEW foo AS
 SELECT ID, CAST(MyLongText as char(255)) AS MyVarchar
 FROM Table
0

精彩评论

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

关注公众号