Category Archives: PostgreSQL

PostgreSQL

Create database:

 

Delete database:

 

Create table:

 

Delete table:

 

Insert

Dump

 

Restore

 

SELECT COUNT(*)

 

Create user

 

Grant privileges

 

Rename column

 

Change password

 

Add auto-increment pk to existing table, where ID is pk

 

Modify sequence number

 

Delete sequence

 

Change column constraint to not null

 

Change column type from integer to smallint

 

Change column type from varchar (20) to varchar (40)

 

Change column type from date to timestamp without time zone

 

Delete column

 

Add column

 

Rename column

 

Add foreign key

 

Delete constraint

 

Delete data

 

Select A where B has 0 entries