当前位置:网站首页>SQL knowledge summary 004: Postgres terminal command summary
SQL knowledge summary 004: Postgres terminal command summary
2022-07-08 00:05:00 【Cloth scholar Python】
I am using postgresql Container created postgresql database , Therefore, the following commands are based on this !
1. Enter into container :
docker exec -it Containers id /bin/bash
2. Command line login database , Enter the database created by default :
The format is :
psql -U username -h ipaddress -d dbname
My is :
psql -U postgres -d postgres
3. List all databases :
postgres=# \l

4. Switch database :
postgres=# \c tododb
among ,tododb Is my other database name
5. List the tables under the current database
Because my database only has postgres There's data in , therefore , First use \c Switch back , Reuse \d View all tables in the database :
postgres=# \d

6. Show current database
postgres=# select current_database()
7. List all the fields of the table
postgres=# \d tablename
8. Check the basic information of the table
postgres=# \d+ tablename
9. Change database password :
alter user postgres with password '654321';
Note that the password is ’ ‘ Enclosed content ! Don't lose the last ; Number , Otherwise nothing can be done .
It's also easy to change the password expiration time :
alter user postgres with valid until '2017-01-01 08:00:00';
If you want to change it to never expire :
alter user postgres with valid until 'infinity';
10. Log out
postgres=# \q
边栏推荐
- Go learning notes (1) environment installation and hello world
- Pycharm basic settings latest version 2022
- 面试题详解:用Redis实现分布式锁的血泪史
- Basic learning of SQL Server -- creating databases and tables with the mouse
- 全自动化处理每月缺卡数据,输出缺卡人员信息
- Introduction to programming hardware
- Tools for debugging makefiles - tool for debugging makefiles
- Kubectl 好用的命令行工具:oh-my-zsh 技巧和窍门
- How did a fake offer steal $540million from "axie infinity"?
- 35岁那年,我做了一个面临失业的决定
猜你喜欢

Basic learning of SQL Server -- creating databases and tables with code

AITM3.0005 烟雾毒性测试

How does starfish OS enable the value of SFO in the fourth phase of SFO destruction?

Problems faced when connecting to sqlserver after downloading (I)

MP4文件格式解析之结合实例分析

【编程题】【Scratch二级】2019.03 绘制方形螺旋
![[programming problem] [scratch Level 2] March 2019 draw a square spiral](/img/fa/ae9dabdd36ba77b1f4644dd23bee93.png)
[programming problem] [scratch Level 2] March 2019 draw a square spiral

某马旅游网站开发(对servlet的优化)

Go learning notes (2) basic types and statements (1)
PostGIS learning
随机推荐
Traduction gratuite en un clic de plus de 300 pages de documents PDF
MP4文件格式解析之结合实例分析
Enterprise application demand-oriented development of human resources department, employee attendance records and paid wages business process cases
10 schemes to ensure interface data security
Problems faced when connecting to sqlserver after downloading (I)
Binary sort tree [BST] - create, find, delete, output
P1308 [noip2011 popularity group] count the number of words
One click installation with fishros in blue bridge ROS
QT and OpenGL: load 3D models using the open asset import library (assimp)
The difference between -s and -d when downloading packages using NPM
LinkedBlockingQueue源码分析-新增和删除
【推荐系统基础】正负样本采样和构造
AWS AWS help error
An example analysis of MP4 file format parsing
Aitm3.0005 smoke toxicity test
Robomaster visual tutorial (1) camera
One click free translation of more than 300 pages of PDF documents
How to put recyclerview in nestedscrollview- How to put RecyclerView inside NestedScrollView?
Visual Studio Deployment Project - Create shortcut to deployed executable
At the age of 35, I made a decision to face unemployment