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
How to make use of SQL (Oracle) to count the size of a string?
提问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
The length function will do it. See http://www.techonthenet.com/oracle/functions/length.php
长度函数会做到这一点。见http://www.techonthenet.com/oracle/functions/length.php
回答by Savke
Regardless to Your example
不管你的榜样
select length('Burger') from dual;
I hope this will help :)
我希望这个能帮上忙 :)