oracle常用函数(1)
1、返回与指定的字符对应的十进制数 select ascii(A) A,ascii(z) a,ascii(12) 一打,ascii( ) kg from dual; 2、返回与指定十进制对应的字符 select chr(65) A,chr(122) z from dual; 3、连接两个字符串 select concat(熊大,熊二) constr from dual;--熊大熊
1、返回与指定的字符对应的十进制数
select ascii('A') A,ascii('z') a,ascii('12') 一打,ascii(' ') kg from dual;
2、返回与指定十进制对应的字符
select chr(65) A,chr(122) z from dual;
3、连接两个字符串
select concat('熊大','熊二') constr from dual;--熊大熊二
4、将第一个字符变大写并返回字符串
select initcap('boat') upperfirst from dual;--Boat
5、将所有字符变成大写并返回字符串
select upper('boat') upperall from dual t;--BOAT
6、将所有字符变成小写并返回字符串
select lower('BoaT') lowerall from dual;--boat
7、INSTR(str1, str2, a,b)函数
用法:得到在str1中包含str2的位置。
从左边开始检查,开始的位置为a,如果a是一个负数,那么是从右边开始进行扫描的,第b次出现的位置将被返回。
a和b都缺省设置为1,这将会返回在str1中第一次出现str2的位置
select instr('zheshigeceshi','sh',-2,1) str from dual;--11 select instr('zheshigeceshi','sh',1,2) str from dual;--11
8、获取字符串长度
select length('boat') len from dual;--4
9、lpad(str,n,[pad_string])函数
参数str:可以是字符或者参数
参数n:是返回的字符串的长度,如果这个数量比原字符串的长度要短,lpad函数将会把字符串截取成从左到右的n个字符;
参数pad_string:是个可选参数,这个字符串是要粘贴到string的左边的字符串,如果这个参数未写,lpad函数将会在string的左边粘贴空格。
select rpad('boat',10,'*') from dual t;--boat****** select lpad('boat',10,'*') from dual t;--******boat
10、ltrim(x,y) 函数
用法:按照y中的字符一个一个截掉x中的字符,并且是从左边开始执行的
只要遇到y中有的字符, x中的字符都会被截掉,直到在x的字符中遇到y中没有的字符为止函数命令才结束,rtrim(y,x)同理
select ltrim('boat','bo') from dual;--at select ltrim('booooobbbbobat','bo') from dual t;--at select rtrim('boat','at') from dual;--bo select rtrim('boaaaaaaaaatttttttaat','at') from dual;--bo
11、substr(string str, int a, int b)函数
参数1:str 要处理的字符串
参数2:a 截取字符串的开始位置(起始位置是0),为负值时表示从尾部开始算起
参数3:b 截取的字符串的长度,如果b超出要处理的字符串的长度,并不会影响返回结果,系统按要处理字符串最大长度返回
如果不用b,则取从a开始的剩余所有字符串
select substr('boatisgood',3,100) subs from dual;--atisgood select substr('boatisgood',3) subs from dual;--atisgood select substr('boatisgood',-3) subs from dual;--ood
12、替换函数
select replace('nba hupu 步行街怎么没有了','步行街','BXJ') from dual;--nba hupu BXJ怎么没有了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To query the Oracle tablespace size, follow the following steps: Determine the tablespace name by running the query: SELECT tablespace_name FROM dba_tablespaces; Query the tablespace size by running the query: SELECT sum(bytes) AS total_size, sum(bytes_free) AS available_space, sum(bytes) - sum(bytes_free) AS used_space FROM dba_data_files WHERE tablespace_

Oracle View Encryption allows you to encrypt data in the view, thereby enhancing the security of sensitive information. The steps include: 1) creating the master encryption key (MEk); 2) creating an encrypted view, specifying the view and MEk to be encrypted; 3) authorizing users to access the encrypted view. How encrypted views work: When a user querys for an encrypted view, Oracle uses MEk to decrypt data, ensuring that only authorized users can access readable data.

Uninstall method for Oracle installation failure: Close Oracle service, delete Oracle program files and registry keys, uninstall Oracle environment variables, and restart the computer. If the uninstall fails, you can uninstall manually using the Oracle Universal Uninstall Tool.

There are three ways to view instance names in Oracle: use the "sqlplus" and "select instance_name from v$instance;" commands on the command line. Use the "show instance_name;" command in SQL*Plus. Check environment variables (ORACLE_SID on Linux) through the operating system's Task Manager, Oracle Enterprise Manager, or through the operating system.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

Deleting all data in Oracle requires the following steps: 1. Establish a connection; 2. Disable foreign key constraints; 3. Delete table data; 4. Submit transactions; 5. Enable foreign key constraints (optional). Be sure to back up the database before execution to prevent data loss.

To create a user in Oracle, follow these steps: Create a new user using the CREATE USER statement. Grant the necessary permissions using the GRANT statement. Optional: Use the RESOURCE statement to set the quota. Configure other options such as default roles and temporary tablespaces.

Oracle Invalid numeric errors may be caused by data type mismatch, numeric overflow, data conversion errors, or data corruption. Troubleshooting steps include checking data types, detecting digital overflows, checking data conversions, checking data corruption, and exploring other possible solutions such as configuring the NLS_NUMERIC_CHARACTERS parameter and enabling data verification logging.
