PostgreSQL examples (example source code) Organized by topic

Select Query /

AND 2AS 1
BETWEEN 2Case 2
Compare Row 1Comparison Operators 3
Constant 1DISTINCT 3
EXCEPT 1EXPLAIN Query 2
Expressions 1Group By 1
Having 2INTERSECT 1
IS NULL 1Like 2
LIMIT 2Mathematical Operators 1
NOT 1NULL 2
OFFSET 1Operator Precedence 1
OR 1Order 5
Query Column 3Query Expressions 1
Quotation 1Row 4
SELECT INTO 1String Compare 1
UNION 3WHERE 6

Insert Delete Update /

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

Subquery /

Subquery Basics 4Subquery Case 1
Subquery IN 2

Table /

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

Table Joins /

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

View /

Create View 3User Permission 1
View Privilege 2

Database /

Comment Database 1Create Database 1
Drop Database 1USING 1

Cursor /

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

Transaction /

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

Store Procedure Function /

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

Postgre SQL /

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

Data Type /

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

Date Timezone /

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

Array /

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

Constraints /

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

Index /

Create Index 4Drop Index 1
REINDEX 1

Sequence /

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

Inheritance /

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

Aggregate Functions /

Aggregate Function 1AVG 1
max 3Min 1
SUM 2

Analytical Functions /

Count 2stddev 2
Variance 2width_bucket 1

String Functions /

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

Math Functions /

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

User Previliege /

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