do
$do$
begin
IF (select count(1) from information_schema.columns where table_schema = 'public'
and table_name = 'user' and column_name = 'name') = 0
then
ALTER TABLE "user" ADD COLUMN "name" varchar(40);
END IF;
end
$do$;
3.如果不存在表user,创建表user
do
$do$
begin
IF NOT( select count(1) from information_schema.tables where table_schema='public' and
table_type='BASE TABLE' and table_name='user') = 1 --一定要加括号
THEN
create table user
(
id varchar(40) not null,
name varchar(40) null,
constraint PK_USER_INFO primary key (id)
);
comment on table useris '用户信息表';