Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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
postgresql无法在架构中创建表_Postgresql - Fatal编程技术网

postgresql无法在架构中创建表

postgresql无法在架构中创建表,postgresql,Postgresql,我正在创建schema/db/。。。使用此脚本: CREATE ROLE testuser LOGIN PASSWORD 'password'; CREATE TABLESPACE testtablespace OWNER testuser LOCATION '/pgdata/pg94/testtablespace'; CREATE SCHEMA testschema; ALTER SCHEMA testschema OWNER TO testuser; CREATE DATABASE test

我正在创建schema/db/。。。使用此脚本:

CREATE ROLE testuser LOGIN PASSWORD 'password';
CREATE TABLESPACE testtablespace OWNER testuser LOCATION '/pgdata/pg94/testtablespace';
CREATE SCHEMA testschema;
ALTER SCHEMA testschema OWNER TO testuser;
CREATE DATABASE testdb WITH TABLESPACE testtablespace ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C' TEMPLATE template0 OWNER testuser;
ALTER DATABASE testdb SET search_path TO testschema, public;
ALTER ROLE testuser SET search_path TO testschema, public;
GRANT ALL ON DATABASE testdb TO testuser;
GRANT ALL ON SCHEMA testschema TO testuser;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA testschema TO testuser;
ALTER ROLE testuser SET default_tablespace = testtablespace;
当我使用命令
psql-U testuser testdb
登录并执行comand
时,从information\U schema.schemata中选择schema\U name。更糟糕的是,我无法在此架构中创建表

testdb=> create table testschema.test (test varchar(10));
ERROR:  schema "testschema" does not exist

请确定我应该配置什么来查看架构并在int中创建表?

create schema
始终适用于当前数据库。您已经在当前数据库(可能是
postgres
)中创建了
testschema
,而不是在
testdb
中。
您应该连接到
testdb
,然后创建新的模式。

有没有办法在不连接该数据库的情况下为某些数据库创建模式?类似于创建模式testdb.testschema的东西?我很惊讶这是不可能的。你可以查一下。