简体   繁体   English

如何在 Oracle SQL 中找到 col 具有特殊字符或数字(连字符、撇号和空格除外)的行

[英]How to find a row where col have special characters or numbers (except hyphen,apostrophe and space) in Oracle SQL

I need to find rows where col have special characters or numbers (except hyphen,apostrophe and space) in Oracle SQL.我需要在 Oracle SQL 中找到 col 具有特殊字符或数字(连字符、撇号和空格除外)的行。

I am doing like below:我正在做如下:

SELECT *
FROM   test
WHERE  Name_test LIKE '%[^A-Za-z _]%'

But It is not working and I also need to exclude any apostrophe.但它不起作用,我还需要排除任何撇号。 Kindly help.请帮忙。

If you need to find all rows where column have ONLY numbers and special characters (and you can specify all of required special characters):如果您需要查找列仅包含数字和特殊字符的所有行(并且您可以指定所有必需的特殊字符):

SELECT *
FROM   test
WHERE  regexp_like(Name_test, q['^[0-9'%#@]+$]')

as you can see you just need to add your special characters after 0-9.如您所见,您只需要在 0-9 之后添加特殊字符。 ^ - start $ - end ^ - 开始 $ - 结束

About format q'[SOMETHING]' please see TEXT LITERALS here: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Literals.html#GUID-1824CBAA-6E16-4921-B2A6-112FB02248DA关于格式 q'[SOMETHING]' 请在此处查看文本文字: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Literals.html#GUID-492EAA-CB66 B2A6-112FB02248DA

If you need to find all rows where column have no alpha-characters:如果您需要查找 column 没有字母字符的所有行:

SELECT *
FROM   test
WHERE  regexp_like(Name_test, '^[^a-zA-Z]*$');

or SELECT * FROM test WHERE regexp_like(Name_test, '^\W*$');或 SELECT * FROM test WHERE regexp_like(Name_test, '^\W*$');

about \W - please see "Table 8-5 PERL-Influenced Operators in Oracle SQL Regular Expressions" here:关于 \W - 请在此处查看“Oracle SQL 正则表达式中的表 8-5 受 PERL 影响的运算符”:

https://docs.oracle.com/database/121/ADFNS/adfns_regexp.htm#ADFNS235 https://docs.oracle.com/database/121/ADFNS/adfns_regexp.htm#ADFNS235

I need to find rows where col have special characters or numbers (except hyphen, apostrophe and space [and presumably single quotes]) in Oracle SQL.我需要在 Oracle SQL 中找到 col 具有特殊字符或数字(连字符、撇号和空格 [以及可能是单引号] 除外)的行。

You can use double single quotes to put a single quote in:您可以使用双单引号将单引号放入:

WHERE  Name_test LIKE '%[^-A-Za-z _'']%'

However, this is not Oracle syntax.但是,这不是 Oracle 语法。 If the above works, then I would guess you are using SQL Server.如果上述方法有效,那么我猜您正在使用 SQL 服务器。 In Oracle:在 Oracle 中:

WHERE REGEXP_LIKE(Name_test, '[^A-Za-z _'']')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Oracle SQL 中找到 col 有字母、数字或特殊字符(连字符、撇号和空格除外)的行 - How to find a row where col have alphabets,numbers or special characters (except hyphen,apostrophe and space) in Oracle SQL 删除Oracle字符串数据中除连字符和空格以外的特殊字符 - Remove special characters except Hyphen and Space in Oracle String Data Oracle SQL 查询查找电话号码的特殊字符 - Oracle SQL query to find special characters for phone numbers 如何在一个oracle sql语句中删除空格、特殊字符和数字 - how to remove spaces, special characters and numbers in one oracle sql statement 如何在字符串中查找特殊字符并将其替换为SQL中的空格? - How to find a special characters in a string and replace it with a space in SQL? 查找除下划线和空格外包含特殊字符的行 - Find rows which contain special characters except underscore and space SQL 代码查找和抑制数字和特殊字符 - SQL code to find and suppress numbers and special characters SQL Oracle:哪里 <Col Val> == <Item in a list of characters> - SQL Oracle: Where <Col Val> == <Item in a list of characters> 如何在Oracle中限制表空间中除空格以外的特殊字符 - how to restrict special character except space in a table in oracle 如何编写 oracle sql 来查找特殊字符 - How to write oracle sql to look for special characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM