postgresql

recent posts related to the postgresql database

Mac OS X Postgresql: How to start a Postgres server on a Mac alvin May 14, 2009 - 3:37pm

Wow, it had been a long time since I last started Postgres on my Mac computer (a MacBook Pro, to be specific), and it took almost almost 20 minutes to remember how to do it. So, to keep that from happening again, here's a quick tip on how to start Postgres (Postgresql) on a Mac OS X computer.

Postgresql error - must be owner of relation alvin November 22, 2007 - 4:37pm

If you get a Postgresql error message like this:

ERROR:  must be owner of relation [your_table_here]

don't worry too much, it probably means what it says: You don't own the table (or relation) you're trying to modify. Well, I guess you can worry if you can't get someone to fix the permissions, but if you can it's no big deal.

Postgresql - How to execute SQL commands from a file alvin November 15, 2007 - 2:44pm

With Postgresql (or Postgres, as I call it) you can execute commands from a file like this:

\i your_file_name_here

I just did that to run a subset of the restore commands from a backup file that I created, and it worked just fine. In my case I put the file in my current working directory, but I'll guess that you can also supply a path to the file and it will work from there as well.

 

How to show Postgres table information alvin February 8, 2006 - 5:58pm

Here you want to use the "describe" command in Postgresql. Assuming that you want to get information about a database table named users, and you're logged into a Postgresql database using the psql client, issue this command at the psql prompt:

\d users

This will provide a description of the table named users. Your output from this command should look like this:

Postgresql - How to list all tables in a Postgresql database alvin February 8, 2006 - 5:52pm

"Postgres show tables" FAQ: How do I list all the tables in my current Postgresql database?

Once you're logged into a Postgresql database using the psql client, issue this command at the psql prompt to show all the tables in your Postgres database:

\dt

This will list all of the tables in the current database.

 

Postgresql - How to list the Postgresql slash commands alvin February 8, 2006 - 5:48pm

Question: How do I list the Postgres slash commands, i.e., the commands available from the Postgres command line?

Once you're logged into a Postgresql database, you can issue the \? command to see the list of available Postgres "slash" commands, like this:

mydatabase=> \?

For my own convenience, I'm listing these Postgres commands here. These are the commands available in the Postgresql 8.0.3 client:

First, I issue the call for Postgres command line help:

Postgres login - how to log into a Postgresql database alvin February 8, 2006 - 5:40pm

"Postgres login" FAQ: How do I log into a Postgres database from the command line?

To log into a Postgres database from the command line, use the psql command. Let's take a look at a few psql command line options you can use.

Postgres login commands

If you are logged into the same computer that Postgres is running on you can use the following psql login command, specifying the database (mydb) and username (myuser):

Practical PostgreSQL book online alvin May 5, 2003 - 1:43pm

Don't know much about the following site, but it does contain an online version of a book titled Practical PostgreSQL.

Postgresql commands - psql list commands alvin June 21, 2002 - 10:40am

Here's a quick tabular list of Postgres commands related to listing information about a Postgres database. (Technically these are "psql commands", because you issue these commands from the psql command line program.)

These Postgres commands help you answer questions like "What tables are in this postgres database?", or "What databases do I have within Postgres?" (a handy question when it comes time for spring cleaning), and other questions. Other popular psql commands are related to permissions, indexes, views, and sequences.

List Postgesql databases (how to)

Postgresql list FAQ: How do I get a list of databases in a Postgresql database?

Just log into your Postgresql database (with the psql command), and then run this command:

\l

(That's a backslash followed by the lowercase letter "L"). This command provides a nice list of all of the Postgresql databases.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.