Difference between revisions of "PostgreSQL"

From WhyAskWhy.org Wiki
Jump to: navigation, search
m (Added commands for logging in, showing databases and tables.)
m (Added database category)
 
Line 1: Line 1:
 
[[Category:NeedsCleanup]]
 
[[Category:NeedsCleanup]]
 
[[Category:Software]]
 
[[Category:Software]]
 +
[[Category:Database]]
  
 
== Character length restrictions ==
 
== Character length restrictions ==

Latest revision as of 10:50, 10 September 2014


Character length restrictions

Using comments

Login

This is probably not the best way, but it's what I've learned to do so far:

sudo su postgres
psql


Connect to a database

\c database_name


Show all databases

  • \list
  • SELECT datname FROM pg_database WHERE datistemplate = false;
    


Show all tables in the current database

  • \dt
  • SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;
    


Create a database

Create a user for that database with full privileges to it

Reset password for user account

Import or run SQL statements from file

Insert a new row

Update field

Delete row

Delete user account

Delete database

Resetting the root user account

Viewing privileges granted to a user

References