Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 在postrgesql 9.4中添加检查约束时出错_Database_Postgresql_Postgresql 9.4 - Fatal编程技术网

Database 在postrgesql 9.4中添加检查约束时出错

Database 在postrgesql 9.4中添加检查约束时出错,database,postgresql,postgresql-9.4,Database,Postgresql,Postgresql 9.4,我是postgresql的新手,我想在friend_type列上添加一个检查约束,但是我得到了错误,我正在尝试下面的查询 ALTER TABLE itapp_friendlist ADD CONSTRAINT check_friend_type friend_type = ANY(0,1,2,3) 我也试过了 ALTER TABLE itapp_friendlist ADD CONSTRAINT check_friend_type (friend_type = ANY('{0,1,2,3}

我是postgresql的新手,我想在friend_type列上添加一个检查约束,但是我得到了错误,我正在尝试下面的查询

 ALTER TABLE itapp_friendlist ADD CONSTRAINT check_friend_type friend_type = ANY(0,1,2,3)
我也试过了

 ALTER TABLE itapp_friendlist ADD CONSTRAINT check_friend_type (friend_type = ANY('{0,1,2,3}'::int[]))
但是他们都给出了以下错误,请帮助我,我知道这不是一个大问题,但我是postgresql的新手,所以请原谅我问这种问题,谢谢

ERROR:  syntax error at or near "friend_type"
LINE 1: ...itapp_friendlist ADD CONSTRAINT check_friend_type friend_typ...
                                                      ^

********** Error **********

ERROR: syntax error at or near "friend_type"
SQL state: 42601

对不起大家,我再次尝试了下面的查询,现在它工作正常,实际上我忘记了添加
check
关键字

 ALTER TABLE itapp_friendlist ADD CONSTRAINT itapp_friendlist_type_check check (friend_type = ANY (ARRAY[0,1,2,3]))