[svlug] SQL ?

Ian Kluft ikluft at thunder.sbay.org
Tue Dec 21 02:34:30 PST 2004

On Tue, Dec 21, 2004 at 06:39:02PM +0900, Ahmed Sarwar wrote:
> hi, this is the firs time i'm trying SQL on my debian
> system. I installed posgresql and created a database,
> table etc. my question is how can i see the source?
> where is my file "testdb" that i created(or it's not a 
> file). i've been google-ing but couldn't find anything 
> specific. thanks in advance.

It isn't just in a simple text file.  I'm not sure if it's configured the
same way on your Debian system, but the PostgreSQL database files are in
/var/lib/pgsql on RPM-based Linux systems where I've used it.

You'll probably find it uninteresting once you look around in the files.
They're all binary and unreadable to text-based tools.  Everything in
a database management system (DBMS) is architected so they can be fast
for their programs to access.  Parsing human-readable text is just too
time-consuming for the kind of processing that these programs do, so
they're designed to discard that in favor of all-out performance.  It's
all stored in machine-readable format only.  The idea is that you only go
through the database software to get to the data, but it will give it to
you in whatever way you want to query for it, as fast as possible.

Now this is not to say that you couldn't read it if you really want to.
For PostgreSQL (and this is also true of MySQL), you have the source code.
If you're inclined to make this a self-educational effort, the file format
is all there for you.  Some of the files under /var/lib/pgsql/data/base
with mysterious numbers for their names and unrecognizable binary contents
are your database's tables.  Once you go that deep into understanding it,
you may even want to ask the PostgreSQL developers where you can help

Every database expert had to start somewhere.  It's up to you how far
you want to go.

More information about the svlug mailing list