如何在一条 SQL 语句中获取 varchar[n] 字段的大小? [英] How to get the size of a varchar[n] field in one SQL statement?

查看:35
本文介绍了如何在一条 SQL 语句中获取 varchar[n] 字段的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个 SQL 表,它有一个名为备注"的 varchar[1000] 字段.

Suppose that I have a SQL table that has a varchar[1000] field called "Remarks".

我想编写一个 SQL 语句,执行时将返回 1000,或者将来可能将 varchar 字段的大小更改为任何大小.

I would like to craft a single SQL statement, which when executed, will return 1000, or whatever the size of the varchar field might be changed to in the future.

类似于SELECT size(Remarks) FROM mytable.

我该怎么做?

推荐答案

select column_name, data_type, character_maximum_length    
  from information_schema.columns  
 where table_name = 'myTable'

这篇关于如何在一条 SQL 语句中获取 varchar[n] 字段的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆