プロが教えるわが家の防犯対策術!

Postgresでインサートコマンドが書かれたファイルを
インポートするだけで値がDBに格納される方法は
どうすればよろしいでしょうか?

oracleでは.sqlという拡張子をつけて
あるコマンドをうつだけだと思いますが・・・

よろしくお願いします。

A 回答 (1件)

OSは何を使っているか?


一番肝心な事が書かれていないので、とりあえずLinuxのPostgresで説明すると、


$ psql -l

    List of databases
  Name  | Owner  | Encoding
-----------+----------+----------
template0 | postgres | EUC_JP
template1 | postgres | EUC_JP
user   | postgres | EUC_JP


$ cat useradd.sql
create table account (name text, password text);
insert into account values ('hoge1', 12345678);
insert into account values ('hoge2', 98765432);


$ psql user < useradd.sql
CREATE TABLE
INSERT 16982 1
INSERT 16983 1
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!