Postgre'lerde bir tablo oluşturmaya çalışıyorum, ancak yanlış veritabanında biter. İştepostgres: tablodaki tabloyu oluştur
benim yaptığım: my sql komut başlangıçta Sonra bir kullanıcı ve bir veritabanı ve tablo oluşturun.
drop database if exists sinfonifry;
drop role if exists sinfonifry;
-- create the requested sinfonifry user
create user sinfonifry createdb createuser password 'some_password';
-- create a sinfonifry database
create database sinfonifry owner sinfonifry;
DROP TABLE if exists sinf01_host;
CREATE TABLE sinf01_host
(
host_id bigserial NOT NULL, -- The primary key
host_ip inet NOT NULL, -- The IP of the host
host_name character varying(255) NOT NULL, -- The name of the host
CONSTRAINT "PK_host" PRIMARY KEY (host_id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE sinf01_host OWNER TO sinfonifry;
şimdi, bu otomatik bir komut parçasıdır ve benzeri komut satırından yürütülür:: Kod daha açıklayacağız
sudo -u postgres psql < create_db.sql
ve zaten sistemde oluşturulan postgres kullanıcı var.
Ve burada problem gelir: tablo değil sinfonifry veritabanı, kamu şema içinde, Postgres, kamu şema bulur.
nasıl istediğiniz veritabanında tablo oluşturabilirsiniz?
sayesinde ve şerefe, f.
bağlayın içinde herhangi bir nesne oluşturmadan önce. – wildplasser