【发布时间】:2020-05-18 01:50:28
【问题描述】:
我们有一个 postgres 设置,老实说,我对数据库操作知之甚少,我的目标是将一个对象添加到名为 websites 的预先存在的表中,然后拥有以下具有属性的对象如下:
"support": {
"desktop": true,
"mobile": true
}
我知道将 supportDesktop 添加为布尔属性非常容易,如下所示:
ALTER TABLE websites
ADD COLUMN "supportDesktop" boolean DEFAULT true NOT NULL;
ADD COLUMN "supportMobile" boolean DEFAULT true NOT NULL;
COMMIT;
我不确定您是否可以使用某种类型的“对象”值,但任何帮助都会很棒!
【问题讨论】:
-
你总是可以尝试 postgres jsonb 数据类型并直接嵌入对象?
标签: mysql sql postgresql