sql 配置postgres的基本命令

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 配置postgres的基本命令相关的知识,希望对你有一定的参考价值。

# Connect to a database with a username
psql <database_name> -U <user_name>

# List all databases
\l

# Connect to a database inside psql
\connect <database_name>

# List all tables in a database
\dt *.*

# Change username's password from psql# prompt after logging in
ALTER USER "<user_name>" WITH PASSWORD '<new_password>';

# Configure a jdbc connection from rubymine. Note: jdbc requires password
Host: localhost
Database: <database_name>
User: <user_name>
Password: <password>
Port: 5432

# dump a database
pg_dump -h localhost -U postgres <database-name> > dumpfile

# dump a table
pg_dump -h localhost -U postgres <database-name> -t <table-name> > dumpfile-table


# to login an rds instance in amazon postgres from command line
psql -h <end-point> -U <username> -d <database>

# to reconstruct aws rds from a dump file in localhost
psql -h <end-point> -U <username> -d <database> < dumpfile-table

# to create a fake database called 'fakelocal' with 200 rows in a table named 'company' in localhost, use fake2db tool
fake2db --rows 200 --db postgresql --name fakelocal --host localhost --port 5432 --username postgres --password password

以上是关于sql 配置postgres的基本命令的主要内容,如果未能解决你的问题,请参考以下文章

markdown Postgres SQL命令备忘单

sql Postgres命令

如何通过 SQL 命令更改 Postgres 的 max_connections

如何在 pyspark Hive SQL 中获取等效的 postgres 命令“nth_value”?

Postgres SQL (Amazon Redshift) 在启动时运行命令

Postgres 列不存在