是否存在用于在SQL文件中内连接数据库的命令?
我想创建一个数据库,然后立即开始用表和数据填充它。全部包含在单个.sql
文件中。我不知道有什么可以代替\c
shell命令吗?
示例SQL文件:
CREATE DATABASE mydb;
CREATE USER myusername WITH PASSWORD 'mypassword';
GRANT ALL PRIVILEGES ON DATABASE mydb TO myusername;
CONNECT TO mydb USER myusername; --<-- something like this?
CREATE TABLE administrator (
id integer NOT NULL,
admin_name character varying(150),
password character varying(255),
active boolean,
"timestamp" timestamp without time zone,
email character varying(255)
);
ALTER TABLE administrator OWNER TO myusername;
CONNECT是我在文档中找到的最接近的东西,但是它遇到语法错误。我也找不到指定表格应该放在哪里的包装器?
ERROR: syntax error at or near "CONNECT"