I'm trying to create a database and add create a table in a single SQL script:
CREATE DATABASE w3;
CREATE TABLE w3.public.examples (
id SERIAL PRIMARY KEY,
text VARCHAR(200) NOT NULL
);
INSERT INTO
w3.public.examples (text)
VALUES
('val1');
INSERT INTO
w3.public.examples (text)
VALUES
('val2');
INSERT INTO
w3.public.examples (text)
VALUES
('val3');
SELECT
*
FROM
w3.public.examples;
When I'm exucuting this script via psql: psql -U postgres -a -f script.sql I'm getting error:
psql:script.sql:26: ERROR: cross-database references are not implemented: "w3.public.examples"
LINE 4: w3.public.examples;
Does it mean I cannot create and use a database in a single SQL file?