使用 IF NOT EXISTS
更新時間 2025-02-14 10:21:49
最近更新時間: 2025-02-14 10:21:49
分享文章
本頁為您介紹如何使用使用 IF NOT EXISTS關鍵字。
帶IF NOT EXISTS 關鍵字作用表示表不存在時才創建。
teledb=# create table t(id int,mc text);
CREATE TABLE
teledb=# create table t(id int,mc text);
ERROR: relation "t" already exists
teledb=# create table IF NOT EXISTS t(id int,mc text);
NOTICE: relation "t" already exists, skipping
CREATE TABLE