我正在为MySql读取information_schema表,因为我正在使用的模式的表具有long作为数据类型。
如图所示
创建表foo ( col1 varchar(40),col2 long,col3 varchar(256) );
如果我在这个表上执行select from information_schema.columns,那么data_type返回为'mediumtext‘。
如何区分long字段和文本字段?
示例sql如下所示:
drop table if exists foo;
create table foo (
col1 varchar(40),
col2 long,
col3 varchar(256),
col4 mediumtext
);
insert into foo values ("This is col 1", 12345, 'This is col 3', 'This is col4');
select * from foo;
select * from information_schema.columns where table_name = 'foo';发布于 2020-09-27 15:10:30
如果您将col2定义为长文本,那么当您查询information_schema.columns时,它将以这种方式出现。long不是mysql中定义的数据类型,但为了便于使用其他供应商的https://dev.mysql.com/doc/refman/8.0/en/other-vendor-data-types.html中为SQL实现编写的代码,它将其映射为mediumtext。
https://stackoverflow.com/questions/64083478
复制相似问题