Postgresql Common Commands

Source: Internet
Author: User
Tags postgresql

The introduction recently collated some of the most common commands for PostgreSQL, for reference 1 only. Common commands:
# time Word Fu timestampSelectExtract (Epoch fromDate'2018-04-11 23:59:59')); #1523404800# Timestamp to time stringSelectDate (To_timestamp (1523404800) # Timestamp to stringSelectTo_char (To_timestamp (1523404800),'YYYY-MM-DD HH24:MI:SS') # Convert numeric typeCAST(T3.userid as text) # int NUMERIC VARCHAR can also

# Default Value
  coalesce(null, 1); # 1

2. Common numeric functions

AVG () returns the average of a column

COUNT () returns the number of rows in a column

Max () returns the maximum value of a column

MIN () returns the minimum value of a column

Sums () returns the sum of the values of a column

3. Commonly used String functions

Lengtah (s) calculates the string length

CONCAT (s1,s2,......) string merge function

Letrim (s)/rtrim (s)/trim (s) Delete string space function

Replace (S,S1,S2) string substitution function

SUBSTRING (s,n,len) Get substring function

4. Commonly used date and time functions

EXTRACT (type from D) Get date specified value function

Current_date getting the current date function

Current_time Get current time

Postgresql Common Commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.