-c, --command=COMMAND run only single command (SQL or internal) and exit -d, --dbname=DBNAME database name to connect to (default: "tony") -f, --file=FILENAME execute commands from file, then exit -l, --list list available databases, then exit -v, --set=, --variable=NAME=VALU...
\connect my_database 确认切换: 如果切换成功,psql 提示符会更新为显示当前连接的数据库名。例如: text You are now connected to database "my_database" as user "your_username". 执行其他操作: 现在你已经成功切换到了目标数据库,可以开始执行 SQL 语句或其他数据库操作了。 通过以上步骤,你就可以...
-d, --dbname=DBNAME database name to connect to (default: "tony") -f, --file=FILENAME execute commands from file, then exit -l, --list list available databases, then exit -v, --set=, --variable=NAME=VALUE set psql variable NAME to VALUE (e.g., -v ON_ERROR_STOP=1) -V, -...
You are now connected to database "postgres" as user "postgres". 12、列出当前连接信息 postgres=# \conninfo You are connected to database "postgres" as user "postgres" via socket in "/data01/pg12/pg_root12000" at port "12000". 13、列出对象信息、权限 S包括系统对象 Informational (options:...
connection = psycopg2.connect(user="your_username", password="your_password", host="your_host", port="your_port", database="your_database") except (Exception, psycopg2.Error) as error: print("Error while connecting to PostgreSQL", error) ...
[DBNAME|- USER|- HOST|- PORT|-] | conninfo} connect to new database (currently "testdb2") \encoding [ENCODING] show or set client encoding \password [USERNAME] securely change the password for a user \conninfo display information about current connection Operating System \cd [DIR] change ...
psql Connect to the database. psql -d <db> -U <user> Connect to localhost db as user name. psql create database <db> Create database with db name. create role <pg_user> with LOGIN ENCRYPTED PASSWORD <password> Create a user pg_user with password. create database <db> owner <user...
如果缺省不太正确,那么你可以通过设置几个环境变量PGDATABASE, PGHOST,PGPORT和/或PGUSER 的方法节约几次敲击。其它环境变量的信息,参阅第31.14 节。另外,用一个~/.pgpass文件来避免输入密码也是很方便的。参阅第31.15 节获取更多信息。 声明连接参数的另一种方式是在conninfo字符串或 URI中,代替数据库名字。这种...
connect to new database (currently "aoldbs") \encoding [ENCODING] show or set client encoding \password [USERNAME] securely change the password for a user \conninfo display information about current connection Operating System \cd [DIR] change the current working directory ...
• 搜索路径search_path • General \c[onnect] [DBNAME|- USER|- HOST|- PORT|-] connect to new database (currently "A") \cd [DIR] change the current working directory \copyright show PostgreSQL usage and distribution terms \encoding [ENCODING] show or set client encoding \h [NAME] ...