Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Database learning Postgresq

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Psql testdb, system login user, local database, connect to testdb database

Psql-U testuser testdb, user testuser, connect to the local database testdb

Psql-U testuser-h 172.28.18.51 testdb, user testuser, connect to remote testdb database

Enumerate databases: / l

Select database: / c database name

Display table structure information: / d table name

Exit psgl:/q

Display character set: / encoding [sroot@AAEP7151 craft] # su postgres

Bash-4.1$ psql VoicePortal

Psql (9.2.14)

Type "help" for help.

VoicePortal=#\ d

Common instruction

Select pg_database_size ('VoicePortal')

SELECT Sname,2016-Sage

From Student; indicates the year of birth

Select DISTINCT Sno eliminates duplicate lines

FROM SC

Select Sname,Sdept,Sage

FROM Student

WHERE Sage NOT BETWEEN 20 AND 23; determine the range is not useful greater than less than, using between and

Selcet Sname .Sex

FROM Student

WHERE Sdept IN ('CS','MA','IS'); the selected major is in this collection

Select Sname

FROM Student

WHERE Sdept = 'CS' OR Sdept =' MA'

List the conditions with or or and

SELECT *

FROM Student

ORDER BY Grade DESC; sort ascending order is ASC descending order is DESC, note that Null is considered to be the largest, ascending order comes last, descending order comes first.

Aggregate function

SELECT COUNT (*)

FROM Sdudent

SELECT AVG (Grade)

FROM SC

WHERE Cno ='1'

Configuration file

/ var/lib/pgsql/data/postgresql.conf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report