簡體   English   中英

使用psql將.sql文件導入postgres

[英]import .sql file into postgres using psql

Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (10.6)
WARNING: Console code page (437) differs from Windows code page (1252)
     8-bit characters might not work correctly. See psql reference
     page "Notes for Windows users" for details.
Type "help" for help.



postgres=#  create database mydb;
CREATE DATABASE
postgres=#  psql -d mydb -f Telnet.sql;
ERROR:  syntax error at or near "psql"
LINE 1: psql -d mydb -f Telnet.sql;
    ^postgres=#

/ *我也無法找出錯誤,但我也嘗試了許多其他命令,但無法找出問題。

您已經在運行psql因此您只能執行SQL命令特定於psql的命令

要連接到新創建的數據庫,請使用psql命令\\c

postgres=# \c mydb

然后提示應更改為

mydb=#

運行SQL腳本psql使用psql命令\\i

mydb=# \i Telnet.sql

請注意, psql命令(以\\開頭的命令) ;終止; -只有SQL命令才需要。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM