PostgreSQL examples (example source code) Organized by topic

Select Query /

Compare Row 1Comparison Operators 3Constant 1DISTINCT 3
EXCEPT 1EXPLAIN Query 2Expressions 1Group By 1
Having 2INTERSECT 1IS NULL 1Like 2
LIMIT 2Mathematical Operators 1NOT 1NULL 2
OFFSET 1Operator Precedence 1OR 1Order 5
Query Column 3Query Expressions 1Quotation 1Row 4

Insert Delete Update /

DELETE ONLY 1Delete 5Insert Select 3Insert 9
Select 6Update 9

Subquery /

Subquery Basics 4Subquery Case 1Subquery IN 2

Table /

Add Column 5Add Comments 1Alter Column 1Column Type 1
Composite Column 3Copy Table 1Create Table 2Drop Table 2
File to Table 2Remove Column 2Rename Column 3Rename Table 2
Table info 1Table Ownership 1Table Previlege 1Table to File 2
Temporary Table 1TRUNCATE 1

Table Joins /

CROSS JOIN 2Full Join 1INNER JOIN 5Left Join 3
LEFT OUTER JOIN 1Natural Join 3NATURAL 1Outter Join 1
Right Join 1Table Join 5

View /

Create View 3User Permission 1View Privilege 2

Database /

Comment Database 1Create Database 1Drop Database 1USING 1

Cursor /

Close Cursor 1Declare Cursor 2Fetch Backward 1FETCH FORWARD 1
FETCH 4Move Cursor 1

Transaction /

Abort 1Begins Transaction 1COMMIT 2Rollback 2
SAVEPOINT 1Transaction Isolation 4

Store Procedure Function /

Create Function 6Drop Function 1Function Call 1Function Parameter 9
Function Return 7Input Alias 1

Postgre SQL /

Assign Variable 2Code Block 3Comments 2Create Language 1
current config 1current_database 1current_schema 3Declare Variable 2
Decode 1Delete Data 1Exception 1File Read 1
For 1generate_series 4If 1Inet Address 2
Inet Port 2Insert Data 2Insert Variable 2Local Variable 1
Log Function 1LOOP 1pg_language 1plpgsql 1
RECORD 1ROWTYPE 3Set Value 3set_config 1
String Calculation 2String Concatenate 4Type 5Update Data 1
VACUUM 1Variable Default 1Version 1While 2

Data Type /

Bit Shift 1Bit 1Boolean 9Cast 4
Float 2Integer 1Money Format 1Money 1
numeric 2Point 4text 2varchar 1

Date Timezone /

current_date 1current_time 1Current_Timestamp 1Date Compare 1
Date Format 1Date Interval format 1Date Time Format 7date 1
DATESTYLE 5date_part 1date_trunc 3extract 1
now 3timeofday 1timestamp 1to_timestamp 1

Array /

Any Array 1Array Column Insert 5Array Column Select 12Array Column Update 6
Array Column 4Array Constructor 1Array Slice 2Array Upper 1
array_append 1array_cat 3array_dims 1array_prepend 1
Concatenate Array 7Nested Array 1

Constraints /

Add Constraints 3Add Primary Key 1Check 2Column Relations 1
CONSTRAINT 1Constraints Basics 4Create Rule 1Default 4
Drop Constraints 2FOREIGN KEY 7NOT NULL 1Primary Key 7
Unique 5

Index /

Create Index 4Drop Index 1REINDEX 1

Sequence /

Create Sequence 2Currval 1Drop Sequence 1nextval 1
Sequence Value 5setval 1

Inheritance /

Children Table 1INHERITS 1Insert Data Children 1Select Inheritance 2
Update Inheritance Only 1Update Inheritance 1

Aggregate Functions /

Aggregate Function 1AVG 1max 3Min 1

Analytical Functions /

Count 2stddev 2Variance 2width_bucket 1

String Functions /

ascii 2btrim 3char_length 2chr 1
get_byte 1ILIKE 1initcap 1length 2
lower 1lpad 1ltrim 3Negation 1
octet_length 2position 2RE Operator 1Regular Expression 3
repeat 1rpad 2rtrim 2set_byte 1
strpos 1substr 6substring 3to_ascii 1
to_char 7to_number 4translate 3trim leading 1
trim trailing 1trim 2upper 1

Math Functions /

abs 2asin 1atan 1atan2 2
cbrt 2ceil 4cos 1cot 1
degrees 2exp 2exponent 2floor 2
isfinite 1ln 3log 5md5 1
mod 2PI 3Pow 2Power 4
radians 1random 2round 3setseed 1
sin 1sqrt 1tan 1trunc 3

User Previliege /

Check Privilege 1Create User 1Current User 1current_user 1
Drop User 1Group Privileges 1REVOKE Privileges 1session_user 1
usecreatedb 1User Privileges 1