CREATE TYPE mpaa_rating AS ENUM (
'G',
'PG',
'PG-13'
);
CREATE TABLE film (
film_id integer DEFAULT nextval('film_film_id_seq'::regclass) NOT NULL,
rating mpaa_rating DEFAULT 'G'::mpaa_rating
);
我尝试了以下内容:
pg_insert($dbconn, "film", new array("rating" => "PG"));
pg_insert($dbconn, "film", new array("rating" => "'PG'::mpaa_rating"));
pg_insert($dbconn, "film", new array("rating" => "PG::mpaa_rating"));
我收到错误:
unknown or system data type
答案 0 :(得分:1)
pg_query($dbconn, "insert into film(rating) values('PG');");
pg_insert
是实验性的,有几个缺点。