SQL 如何利用SQL(Oracle)统计一个字符串的大小?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6569276/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 11:11:47  来源:igfitidea点击:

How to make use of SQL (Oracle) to count the size of a string?

sqlstringoraclecount

提问by Oh Chin Boon

i was wondering if there was a function in Oracle to count the number of character size in Oracle, i.e. given "Burger", the SQL returns 6.

我想知道 Oracle 中是否有一个函数来计算 Oracle 中字符大小的数量,即给定“Burger”,SQL 返回 6。

i.e. select XXX('Burger') from DUAL; 

回答by álvaro González

You can use LENGTH()for CHAR / VARCHAR2 and DBMS_LOB.GETLENGTH()for CLOB. Both functions will count actual characters (not bytes).

您可以将LENGTH()用于 CHAR / VARCHAR2,将DBMS_LOB.GETLENGTH()用于 CLOB。这两个函数都将计算实际字符(而不是字节)。

See the linked documentation if you do need bytes.

如果您确实需要字节,请参阅链接的文档。

回答by heximal

you need length() function

你需要 length() 函数

select length(customer_name) from ar.ra_customers

回答by DoctorMick

回答by Savke

Regardless to Your example

不管你的榜样

select length('Burger') from dual;

I hope this will help :)

我希望这个能帮上忙 :)