Sql 在红移中使用正则表达式

Sql 在红移中使用正则表达式,sql,regex,amazon-redshift,Sql,Regex,Amazon Redshift,这个查询在mysql中工作,但我不知道如何在redshift/postgresql中编写相同的查询 update customer_Details set customer_No = NULL WHERE customer_No NOT REGEXP '^[[:digit:]]{12}$' 你需要使用。像这样的方法应该会奏效: UPDATE customer_details SET customer_no = NULL WHERE customer_No !~

这个查询在mysql中工作,但我不知道如何在redshift/postgresql中编写相同的查询

update customer_Details set
customer_No = NULL
WHERE customer_No NOT REGEXP '^[[:digit:]]{12}$' 
你需要使用。像这样的方法应该会奏效:

UPDATE
    customer_details 
SET 
    customer_no = NULL 
WHERE 
    customer_No !~ '^[[:digit:]]{12}$';
你需要使用。像这样的方法应该会奏效:

UPDATE
    customer_details 
SET 
    customer_no = NULL 
WHERE 
    customer_No !~ '^[[:digit:]]{12}$';

红移基本上是postgres 8.3的一个分支,它使用postgres的正则表达式语法:

update customer_Details set
customer_No = NULL
WHERE customer_No ! ~ '^[0-9]{12}$' 

红移基本上是postgres 8.3的一个分支,它使用postgres的正则表达式语法:

update customer_Details set
customer_No = NULL
WHERE customer_No ! ~ '^[0-9]{12}$' 

非REGEXP
替换为
~。您可以将regex模式进一步缩短为
^\d{12}$
非REGEXP
替换为
~。您可以将regex模式进一步缩短为
^\d{12}$