所以我是Postgres的新手,我正在尝试创建一个使用INHERITS子句的表。
无法弄清楚为什么我会收到语法错误(postgres 9.1):
CREATE TABLE images (
id SERIAL,
description VARCHAR NOT NULL,
filename VARCHAR NOT NULL,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted TIMESTAMP DEFAULT NULL,
PRIMARY KEY(id)
);
CREATE TABLE posts (
id SERIAL,
title VARCHAR(50),
body_text VARCHAR,
image_id INTEGER,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted TIMESTAMP DEFAULT NULL,
PRIMARY KEY(id),
FOREIGN KEY(image_id) REFERENCES images(id)
);
CREATE TABLE events (
date_time DATETIME NOT NULL,
venue VARCHAR(50) NOT NULL,
booking_details VARCHAR NOT NULL,
) INHERITS (posts);
错误
psql:2.sql:30: ERROR: syntax error at or near ")"
LINE 6: ) INHERITS (posts);
^
答案 0 :(得分:2)
booking_details VARCHAR NOT NULL,
删除逗号