Home  >  Article  >  Database  >  How to query character length in oracle

How to query character length in oracle

WBOY
WBOYOriginal
2022-01-06 16:37:5515149browse

In Oracle, you can use the select statement and length() function to query the length of a specified character. The select statement is used to query the results under specified conditions. The length() function is used to obtain the length of the specified character. The syntax is: "select length(field name) from table name".

How to query character length in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to query the character length in oracle

You can use

select length(字段名) from 表名;

This sentence is to look at the length of all fields in the table

Oracle's functions length() and lengthb() to get the length of a string

  • --lengthb(string) calculates the length of bytes occupied by string: returns the length of the string Length, unit is byte

  • --length(string) calculates the length of characters occupied by string: returns the length of the string, unit is character

--For single-byte characters, lengthb() and length() are the same

--You can use lengthb('string')=length('string') to determine whether the string contains Chinese characters

Examples are as follows:

 select length('::') from dual;  --结果是 2字符
select lengthb('::') from dual;  --结果是 6字节

Recommended tutorial: "Oracle Tutorial"

The above is the detailed content of How to query character length in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn