postgresql 谨慎使用正则删除(%,_)

  1. 建表
CREATE TABLE public.ellistest (
	id bigserial NOT NULL,
	"name" varchar null,
	primary key (id)
);
  1. 插入数据
    postgresql 谨慎使用正则删除(%,_)_第1张图片
  2. 删除含有_线的数据

你会发现表被清空了

delete from ellistest  where name like '%_%'

原因

  • 百分号(%)用于表示0、1或多个字符或数字。

  • 下划线通配符(_)用于表示一个字符或数字。这些符号也可以组合在一起。如果LIKE操作符不与这两个符号一起使用,它的作用就像等号操作符一样。

https://www.guru99.com/postgresql-like-query.html

你可能感兴趣的:(postgresql,postgresql,数据库)