当前位置:网站首页>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
边栏推荐
- Two small problems in creating user registration interface
- How to measure whether the product is "just needed, high frequency, pain points"
- Problems faced when connecting to sqlserver after downloading (I)
- 一个测试工程师的7年感悟 ---- 致在一路独行的你(别放弃)
- Uic564-2 Appendix 4 - flame retardant fire test: flame diffusion
- UIC564-2 附录4 –阻燃防火测试:火焰的扩散
- PostGIS learning
- [programming problem] [scratch Level 2] December 2019 flying birds
- codeforces每日5题(均1500)-第八天
- STM32F1與STM32CubeIDE編程實例-旋轉編碼器驅動
猜你喜欢
Relevant methods of sorting arrays in JS (if you want to understand arrays, it's enough to read this article)
new和delete的底层原理以及模板
一份假Offer如何盗走了「Axie infinity」5.4亿美元?
自动化测试:Robot FrameWork框架90%的人都想知道的实用技巧
UIC564-2 附录4 –阻燃防火测试:火焰的扩散
Chisel tutorial - 04 Control flow in chisel
[basis of recommendation system] sampling and construction of positive and negative samples
Basic learning of SQL Server -- creating databases and tables with code
10 schemes to ensure interface data security
如何衡量产品是否“刚需、高频、痛点”
随机推荐
P5594 [xr-4] simulation match
STM32F1与STM32CubeIDE编程实例-旋转编码器驱动
One click free translation of more than 300 pages of PDF documents
[leetcode] 20. Valid brackets
全自动化处理每月缺卡数据,输出缺卡人员信息
Chisel tutorial - 05 Sequential logic in chisel (including explicit multi clock, explicit synchronous reset and explicit asynchronous reset)
Apng2gif solutions to various problems
Robomaster visual tutorial (10) target prediction
An example analysis of MP4 file format parsing
Go time package common functions
Solutions to problems in sqlserver deleting data in tables
【编程题】【Scratch二级】2019.03 垃圾分类
P1067 [noip2009 popularity group] polynomial output (difficult, pit)
某马旅游网站开发(对servlet的优化)
Magic fast power
P1308 [noip2011 popularity group] count the number of words
【推荐系统基础】正负样本采样和构造
C language greedy snake
Chisel tutorial - 00 Ex.scala metals plug-in (vs Code), SBT and coursier exchange endogenous
【編程題】【Scratch二級】2019.12 飛翔的小鳥