Hi,
In MySQL it is just SHOW TABLES. But what about PostgreSQL? How do I list all tables in a PostgreSQL database using a query?
I know the \d command and yes, I've searched the forum and the web.
PostgreSQL: how to query the DB to get all tables in it?
Moderator: General Moderators
For a list of databases type (at the command line) 'psql -l'.
From inside the psql monitor, just try '\l'.
If you want to get database-specific attributes, such as tables, views, etc... just try typeing '\?' from the psql monitor, and you will get a list of nice functions. ('\dt' will list all tables, for example).
(from http://forums.devshed.com/t38544/s.html)
From inside the psql monitor, just try '\l'.
If you want to get database-specific attributes, such as tables, views, etc... just try typeing '\?' from the psql monitor, and you will get a list of nice functions. ('\dt' will list all tables, for example).
(from http://forums.devshed.com/t38544/s.html)
Thanks for the reply although it is a cross post. I mean it, it must be a query. I know the \* commands such as \d and \l, but what I want to do is something like this:
but using a PostgreSQL database and, obviously, PostgreSQL functions.
Regards,
Fëanor.
Code: Select all
<?php
$sql = "SHOW TABLES";
$result = mysql_query($sql);
while ($row = mysql_fetch_row($result))
echo $row[0], "<br />";
?>Regards,
Fëanor.
oops
you may want to check out this article then :
http://www.devshed.com/Server_Side/PHP/ ... page2.html
also, check out the reference guide available on php.net here :
http://www.php.net/manual/en/ref.pgsql.php
you may want to check out this article then :
http://www.devshed.com/Server_Side/PHP/ ... page2.html
also, check out the reference guide available on php.net here :
http://www.php.net/manual/en/ref.pgsql.php
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Hello Fëanor, welcome to PHPDN.
Click here, try the very *first* link returned by Google and you'll get this:
).
Cheers,
Scorphus.
It seems that your search was not that deep enough, see:Fëanor wrote:(...) and yes, I've searched the forum and the web.
Click here, try the very *first* link returned by Google and you'll get this:
Hope that helps (coding, searching and postingpassion at monkey dot org (on [url=http://www.php.net/pgsql]LXXXII. PostgreSQL functions[/url]' User Contributed Notes) wrote:(...) SELECT relname FROM pg_class WHERE relname !~ '^pg_' (...)
Cheers,
Scorphus.