Redshift で非 ASCII 文字をフィルタする。
- テーブルを作成する。
CREATE TABLE source_table ( col1 VARCHAR(100) ); CREATE TABLE target_table ( col1 VARCHAR(100) );
- 非 ASCII 文字を含むレコードを insert する。
insert into source_table values('ascii text1'); insert into source_table values('非ASCIIテキスト1'); insert into source_table values('ascii text2'); insert into source_table values('非ASCIIテキスト2');
- 非 ASCII 文字をフィルタして別テーブルに insert する。
insert into target_table (select * from source_table where REGEXP_INSTR(col1, '[^[:print:][:cntrl:]]') = 0);
- target_table に ASCII 文字のみが insert されていることを確認する。
select * from target_table; col1 ascii text1 ascii text2 (2 rows)