[英]Insert two or three values in a column in the postgresql database
there is postgresql database named movie_db, and created a table named films as following: 有一个名为movie_db的PostgreSQL数据库,并创建了一个名为films的表,如下所示:
CREATE TABLE movies (
title varchar(128) NOT NULL,
description varchar(256) NOT NULL,
directors varchar(128)[],
roles varchar(128)[]
);
I want to insert the following data: 我要插入以下数据:
title description directors roles
a the love of wind tom tom, kaon, kate
b the second way story john jack, mark
for example, you know the movie has not just one actor, for example, movie has the actor(roles): tom, kaon, and kate. 例如,您知道电影不只有一个演员,例如,电影有一个演员(角色):汤姆,凯恩和凯特。 I want to insert these two data into the table using the following command:
我想使用以下命令将这两个数据插入表中:
insert into movies(title, description, directors, roles) values('a',
'the love of wind', 'tom',{'tom, kano, kate'}))
but there is error: 但是有错误:
ERROR: syntax error at or near "{"
LINE 1: ...ors, roles) values('a', 'the love of wind', 'tom',{'tom,
kan..
^
Could you help me to deal with it, thanks for your help! 您能帮我解决这个问题,谢谢您的帮助!
Thanks@a_horse_with_no_name, I solved it, after I read the document about array in the postgresql document. 谢谢@a_horse_with_no_name,在阅读postgresql文档中有关数组的文档后,我解决了它。
The answer about my issue posed: 关于我的问题的答案是:
insert into movies(title, description, directors, roles) values('a',
'the love of wind', '{"tom"}','{"tom", "kano", "kate"}');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.