Jump to content
IvanGS

nomes de tabelas

Recommended Posts

IvanGS

boa tarde gostaria de saber se dá para saber os nomes das tabelas com SQL do género

tenho um base de dados e queria fazer uma listagem dos nomes de todas as tabelas que lá tenho, será possível?

Cumprimentos Ivan Santos

Share this post


Link to post
Share on other sites
Rechousa

Depende do SGBD que estiveres a usar.

Por exemplo, para SQL Server podes usar o seguinte:

SELECT * FROM sys.tables ORDER BY name ASC
SELECT * FROM sysobjects where xtype='U' ORDER BY name ASC
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME ASC

São três formas diferentes de listar as Tabelas da base de dados actual.


Pedro Martins

Sharing is Knowledge!

http://www.linkedin.com/in/rechousa

Share this post


Link to post
Share on other sites
IvanGS

já está resolvido

eu uso o MySQL

como isto era para interagir com PHP resolvi assim:

$sql_show_tables = "SHOW TABLES FROM $database LIKE $mounth";
$result_show_tables = mysql_query($sql_show_tables);

while ($row_show_tables = mysql_fetch_row($result_show_tables)) {
    echo "Table: {$row_show_tables[0]}<br>";
}

mas obrigado na mesma

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.