Category Archives: PostGreSQL

ERROR: column “category” does not exist

I’ve recently switched from SQLite3 to PostGreSQL and came across the following error this morning:

my_app_development=> select category from codes;
ERROR:  column "category" does not exist
LINE 1: select category from codes;

The following post solved the issues in one sentence:

Yes. In postgres, unquoted column and table names are converted to lower case.

The user also added that when using PostGreSql you should either be always, or never using quotes around column names.

Connect to Database – PostGreSQL

This is just a quick post on how to connect to particular database via the console in PostGreSQL. First, make sure you’ve logged in – just swap my_app for your role name:

chris@chris-VirtualBox:~/site$ psql postgres my_app

Password for user site: 
psql (8.4.10)
Type "help" for help.

Finally, all you have to do to connect is the following:

postgres=> \c my_app_development

psql (8.4.10)
You are now connected to database "my_app_development".
my_app =>

If you’re having trouble working out what database name you’re trying to connect to you can view a list of all the current database with the following command:

my_app => \l

 List of databases
       Name       |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges   
 postgres         | postgres | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | 
 my_app_development | site     | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | 
 my_app_production  | site     | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | 
 my_app_test        | site     | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 | 
 template0        | postgres | UTF8     | en_AU.UTF-8 | en_AU.UTF-8 |

my_app => \q -- \q to exit database list